Most voted "c++" questions
C++ is a typed, compiled, multi-paradigm, intermediate level, and general purpose programming language. It should not be confused with the language C. It was developed in the early 1980s by Bjarne Stroustrup as an extension of C. Its evolutionary features include type checking, support for automatic resource management, object orientation, generic programming and treatment of exceptions, among others.
Learn more…2,348 questions
Sort by count of
-
1
votes3
answers187
viewsWhat do these operators " > " and " mean? "
The code below is part of an algorithm that shows the height of a binary tree: int left = height(p->left); int right= height(p->right); int larger = (left > right? left : right); return 1 +…
-
1
votes1
answer77
viewsProject shared with Cmake
I have a project with the following extrusion: Projeto A: | CMakeLists.txt | main.cpp | #include "ProjetoB/ClassB.cpp" | #include "ProjetoC/ClassC.cpp" | vendor/ | Projeto B: | CMakeLists.txt |…
-
1
votes1
answer87
viewsProblem due to queuing
I’m trying to create a queue with structs, but it’s not working the assignment section on lines 17/18, I can’t find the error. The logic I’m using is correct? error: request for member 'nome' in…
c++asked 7 years, 7 months ago Tiago Silveira 665 -
1
votes2
answers167
viewsHow to limit a function parameter so that it is an element of a set?
My intention is to define a function that allows to simulate the execution of a deterministic finite automaton (DFA) datum. According to the formal definition a DFA is the 5-upla M = (Q, Σ, δ, q0,…
-
1
votes0
answers134
viewsParallelization of Bubblesort Open-MP C++
I’m trying to paralyze the bubblesort algorithm using Open-MP and C++, and the parallelization strategy is pipe. The following code, to me, makes sense, but it doesn’t work, and only sorts the…
-
1
votes1
answer100
viewsHow to apply "goto" to quicksort? (c, c++)
I’m doing a job for my college where I ask for a quicksort algorithm to be done in C, using "goto" as much as I can. In the code below I applied the "goto" as far as my knowledge allows, but I would…
-
1
votes1
answer104
viewsC++: Vector in a function
I’m doing a project where I use many vector vectors. Only working with array vectors is easier, so I did the following function: // add.cpp vector <string> sAdd (string In[]) { vector…
-
1
votes1
answer463
viewsHow to remove all nodes from a circular list?
I’m having a hard time getting the logic of how to remove all nodes from a circular list, if someone could give a brief explanation of concept and / or point out the errors in the code I’ve already…
-
1
votes1
answer196
viewsDoubt with the ternary operator
Which means the following expression: struct Node *temp = root->left ? root->left : root->right; I’m wondering if he’s checking the existence of the pointer root->left or comparing *temp…
-
1
votes0
answers65
views -
1
votes1
answer215
viewsParallel programming Qt C++
I’m starting to learn parallel programming, and I’m looking to compare a program with a single thread with a multi thread. What I thought was to make a very simple algorithm that, in a 1-minute…
-
1
votes2
answers1323
viewsCan I replace Cout and printf?
What’s the difference between cout and printf? I learned using the printf and the scanf, but in an online course I see the teacher using cout and some pages also use cout, but others use printf... I…
-
1
votes1
answer131
viewsHow do I create a somaCum() function for Adian? C
Angles ang = {0.0,46.0,91.2,134.7,179.2}, the unit is deg (steps). I have to implement code that initializes the values as a global array, and then defines the void somaCum(float arr[]){} function…
-
1
votes1
answer361
viewssystem() does not accept string type variable in c++
In order to automate some backups that need to be done routinely, so I thought of using an dos to do, but I’m having trouble compiling the executable because it seems to me that the function…
-
1
votes1
answer116
viewsHow to use Lock Functions (Lock Routines) from Openmp?
I need to create 5 easy-to-understand algorithms for each of the blocking functions below in C or C++ to be able to exemplify how each one works and present to my office staff.…
-
1
votes0
answers204
viewsSFML build error in Code::Blocks
I need to make a game for a college subject using the SFML library and the C++ language. I followed this tutorial to configure the Code::Blocks, and pasted the following test file indicated in the…
-
1
votes1
answer1616
viewsCircular List Double chained in C/C++
I’m having trouble removing the first and last element of this circular list. // Created by Thiago Cunha on 25/05/2017. // #include "double_linked_list_circular.h" int count = 0; List* init() {…
-
1
votes1
answer658
viewserror: field has incomplete type
I get this mistake error: field has incomplete type by doing something like: class MinhaClasse { MinhaClasse teste; // Erro aqui }; I already tried to add this line at the beginning of the code…
-
1
votes0
answers70
viewsCombination of several items
I have a set of items and each item has the following elements: E = (índice, espessura, largura, demanda) i = índice; e = espessura; l = largura; d = demanda; I have two more variables: int min,…
-
1
votes1
answer730
viewsUse Import or Include in C/C++?
#import <stdio.h> or #include <stdio.h> What is the correct way to use? I’ve been watching videos on Youtube for a while.…
-
1
votes1
answer59
viewsHow to define a subclass of an abstract class so that it is concrete
With these classes: class SerVivo { public: virtual void funcA() = 0; virtual void funcB() = 0; }; class Vegetal : public SerVivo{ public: virtual void funcB(){ cout << "funcB em Vegetal \n";…
-
1
votes1
answer47
viewspstree in c++ program
The process tree should be displayed at the start of the execution, at the time where all processes are created and at the end of the program. (pstree -s ) This requirement above in bold is part of…
-
1
votes0
answers523
viewsBinary tree - Browse and display elements
I would like to know how to go through and display the values of the tree in post-order, tried various shapes and could not. #include <cstdlib> #include <iomanip> #include…
-
1
votes3
answers1242
viewsPoint inside a polygon
I need to create a function that checks if a point is inside a polygon. For this, I researched on the Internet some solutions that can help me. I found one that seems to be of great help, but in one…
-
1
votes1
answer40
viewsC++: Error with Function Template
I created a function using feedback as demonstrated in that reply, in this way: utilits. h ... template<typename T> bool theres(T a, vector<T> b); ... cpp utilities. ...…
-
1
votes1
answer216
viewshttp connection to c++ and Curl or any other library
I need to request https and http url. I found several libraries, some easy, some not so easy, but the only one I could install was Curl. I’ve taken several examples, the problem is that in the…
-
1
votes2
answers94
viewsHow to omit char matrix size in the function?
I have a question now, I have a function implemented this way: mostrarMensagem(char msg[10]) { //aqui faço algo com a variável "msg". } however I do not know the size I will receive as real…
-
1
votes1
answer88
viewsStoring in a vector without pressing ENTER at each insertion
It is necessary to store a sequence of numbers in a vector, but pressing ENTER only at the end of the line. For example: ENTRADA: 10 20 30 15 50 <ENTER> Vetor[] = {10, 20, 30, 15, 50}…
-
1
votes0
answers555
viewsPlay Tic-tac-toe with Minimax. Problem printing moves
Me and two other friends are doing an old game in C using Minimax and tree as a Data Structure project and we are having trouble receiving the move, and also when showing it to the user. We believe…
-
1
votes2
answers3232
viewsAssign one class to another in C++
There is a class as below: class vetor { protected: int x, y; public: //Construtor vetor(int _x=0, int _y=0); }; and another: class pos : public vetor { public: //Construtor pos();…
-
1
votes1
answer31
viewsPass parameter to a get method, can it generate an error in C++?
I’m starting to study POO now and it’s a bit weird for me. But I’d like to know if I pass some parameter in a method get, can result in a mistake? Ex: class MostraNum { private: int x; public: int…
-
1
votes1
answer156
viewsAssociating stack with struct in C++
Construct the following program: #include <iostream> #include <stack> using namespace std; struct Register{ string name; int birth; char sex; void Insert(string st_name,int st_birth,…
-
1
votes1
answer424
viewsHow to create a mapped file with an Std::map
I’m trying to use a Std::map that allocates objects within a file mapped using boost, with a vector worked but with a map not #include <boost/interprocess/managed_mapped_file.hpp> #include…
-
1
votes0
answers32
viewsIs there any (viable) way to develop Windows software on Linux? Any application for this?
I’m trying to create a cross-Plataform application (for academic reasons), which at least works on Windows and Linux. For development I can only use standard libraries of c/c++ and the native API of…
-
1
votes0
answers47
viewsNot returning the value when using the QT C++ query
When I use the following query to return the database data code, the following message appears: Qsqlquery::value: not positioned on a Valid record Use the same model code and the same is working,…
-
1
votes1
answer664
viewsHow to create one class inside the other in C++?
I need to create one class inside the other in C++ For example: I already have the Calculator class created. I need to insert the Operator class within it. How should I create it? How will the…
-
1
votes1
answer173
viewsError in covering from int to int*
I wanted to know why you are causing the error: Error converting int to int*' This program is only for training the use of pointers in parameters. void teste(int *t){ *t = 50; } int main(){ int x =…
-
1
votes1
answer188
viewsValidating extensions of regex files in c++
personnel I made a function to validate extensions of files using the regex of c++ however it is validating extensions outside the regex I tried to do something to change it but could not get anyone…
-
1
votes0
answers36
viewsIs there any cross-platform way to use keyboard arrows in c++?
In windows has the library conio.h. if I am not mistaken it is possible to use the arrow keys on the keyboard on Linux using ncurses. h, but I wanted a more cross-platform solution where the same…
-
1
votes1
answer55
viewsFunction per parameter does not modify variables
I built a binary tree class in which I have a function bfs that goes all the way through it. As a parameter this method receives a function pointer void (*Op) (node_BT <type> *) that will be…
-
1
votes1
answer161
viewsC++: Vector division<unsigned char>
I’m making a dynamic numeric class, storing the value of the number in a vector of bytes. I did the functions of summation, subtraction and multiplication in the same way that we learn in school,…
c++asked 7 years, 4 months ago Felipe Nascimento 417 -
1
votes2
answers263
viewsHow to avoid array overflow in C++?
My show was exhibiting some weird behavior, until I found out that there was a bang of array, for example: int arr[3]; for (int i = 0; i<10; i++) { arr[i]=i; cout << arr[i]; } In this clear…
-
1
votes1
answer616
viewsHow to call a method within the class?
I’m trying to call the method that returns a unsigned char through another method of the same class, I reviewed the whole internet but did not understand how to do it. byte…
-
1
votes1
answer2467
viewsHow to count the total Characters of a txt file, including spaces and ' n'?
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { FILE *arquivoRead; FILE *arquivoEscrita; char ch; int count=0; int lin, col;…
-
1
votes2
answers76
viewsWhat is wrong with the logic of this code that sums bands of numbers?
My algorithm needs to sum all the values between a and b, for example if I type a=3 e b=6 the program needs to speak 3 7 12 18 (3+4= 7/ 7+5=12 / 12+6=18) only he only makes the first two then starts…
-
1
votes1
answer64
viewsHelps in the logic of conditions and repetition in C++
I have the following verification code to know if a certain number belongs to a vector. I couldn’t think of a more precise way to get the program to say that the number DOES NOT belong to the…
-
1
votes2
answers217
views -
1
votes0
answers65
viewsHow to use glVertexAttribPointer() function correctly for repeated attributes
Hello! I’m trying to render a cube all red, but did not want to specify the color for all vertices in order to save space. For example, we would do so in the traditional way: GLfloat vertices[] = {…
-
1
votes1
answer275
viewsHow to put classes inside vector and manipulate variables with push_back?
It’s definitely something simple, but I researched and didn’t understand how to do. If I have for example the following class, with two variables: class x { public: int var1, var2; }; I want to…
-
1
votes2
answers74
viewsHow to find the data type of a binary file
One problem I often face is figuring out what kind of data to use to store the contents of a binary file. For example when I start a simpler emulator project like CHIP8 or Gameboy, I usually use an…