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
-
2
votes2
answers164
viewsIs it worth using Assembly, C and C++ in the same program?
To optimize and make the program faster, it would be useful or necessary for me to do everything I can in Assembly, what I can not do Assembly, I do in C, and what I can not do in C++? References:…
-
2
votes1
answer169
viewsHow do you create an optional parameter in a class method?
I know that to create an optional parameter in a function you can do this: void exemplo(int a,int b=0); But how do I do it in a class function ex: class Exemplo{ public: void nada(int,int); }; void…
-
2
votes1
answer59
viewsWhat happens when using namespace within a namespace?
What happens when I use the directive using namespace x within a namespace? For example: namespace x { int k = 1; } namespace y { using namespace x; } Now when I use the namespace y can access…
-
2
votes1
answer64
viewsHow to declare a boolean Operator()?
I understand what it does and its usefulness, however, during the researches I did found contradictory information regarding the syntax of a boolean operator. I found 2 syntaxes: bool operator()…
-
2
votes1
answer95
viewsDepth Test is not working properly in Opengl
I’m having a problem with the Depth Test. I have a scene where it contains three objects. A plane a cube and a cylinder. In my Render I am doing for when rendering the cube it should disable the…
-
2
votes1
answer279
views -
2
votes1
answer51
viewsCopy and move constructors are called only in the creation of an object?
The builders move and copy are only called in the creation of an object? if yes, after the creation of an object, it is not possible to call either explicitly or implicitly the move or copy…
-
2
votes1
answer54
viewsHelp with While in c++
I was curious about the following code in c++. int main(int argc, char** argv) { float n1,n2,n3,n4; int i = 1; char nomeAluno; printf("Digite seu nome: "); scanf("%s", &nomeAluno);…
-
2
votes1
answer216
viewsWhen I create a function in C++ do the variables within it stay in memory?
When I was studying pseudocode, I learned that when you call a function and create a variable, it only "exists" when I call that function, for example. funcao teste(): x = 10 retorna x In case, when…
-
2
votes1
answer105
viewsC++ Std::string.c_str() always returning NULL
I recently asked a question, because istreambuf_iterator does not work on android NDK, as I had no answer I decided to investigate myself, I created a project in Visual Studio 2017, simple thing,…
-
2
votes1
answer49
viewsOpen Dynamics Engine does not recognize collision between cylinders
I’m using the library ODE (Open Dynamics Engine) to simulate physics in my application. To create the bounding box and cylinder geometry I am using the following code dMass m1;…
-
2
votes1
answer374
viewsHow to add an element at the end of a linked list
I need to add an element at the end of a linked list, I did the method asking it to add as if it were an initial element if the list is empty (it is working) and, if it is not, scrolling through the…
-
2
votes1
answer236
viewsProblems with C++ threads
Hello, I’m using mingw, 32-bit version in windows 7 Ultimate and I’m having trouble using threads. I know they don’t work for this version of mingw, which is why I use the version in this link. But…
-
2
votes1
answer90
viewsFile build error . cpp using Mingw
Today I reinstalled Mingw and set it up again, I tried it several times with some programs in c++ and it was working fine, but now I try to create new programs and when I will compile using the…
-
2
votes1
answer133
viewsCreate "drawings" with windows API
Hello, I need help with the windows API when it comes to handling "drawings". My problem is that if you resize or minimize the window, everything that was printed on the console disappears. This is…
-
2
votes1
answer211
viewsSnake game, attempt of a beginner C/C++
Hello, I’m doing the snake game, but I’m doing it with a matrix, the way I’m doing it is to give prints and system("cls") quickly, but I’d like to know more efficient ways, like by expelling gotoxy…
-
2
votes2
answers765
viewsData structure in c++
Hello, when I learned C I did several libraries, since Heaps, binary trees, lists, queues...etc I wonder if in C++ there are libraries that we can import to use more easily, as with libraries…
c++asked 6 years, 3 months ago Fábio Morais 1,522 -
2
votes1
answer145
viewsSwitch entering wrong case
I’m trying to solve the Uri 1038 problem using switch, apparently the values are merging, Item 3 for example, multiplying by 2 (5 x 2) returns the value 3. What I’m doing wrong here? #include…
-
2
votes0
answers53
viewsLED Alloy - ARDUINO
Hello, I am a student of electrical engineering and I need to create a code that updates the reference values to light 3 different Leds in all possible combinations, the programming language is for…
-
2
votes1
answer7520
viewsQt SQL - ERROR (42601): syntax error at or near
I am currently developing a program to assist in the management of a barracks in my city, I am using Qt to create the graphical interface and other libraries needed as the manipulation of databases,…
-
2
votes1
answer59
viewsSingleton implementation static member error
When implementing the Singleton standard the compiler gives the following error: include graphdata. h|21|error: 'constexpr' needed for in-class initialization of Static data Member 'graphdata*…
-
2
votes1
answer57
viewsWarning: "No local application has been provided. You can set it in the Run menu, Parameters" Dynamic DLL Creation Problem in C++ in DEV++
I am trying to create a DLL with the code that the teacher passed, but it does not compile correctly. Keeps appearing the warning: "No local application provided. You can set it in the Run menu,…
-
2
votes1
answer154
viewsSort from minor to major in priority_queue unpacking by second element, is it possible?
I’m studying priority_queue and a question has arisen, if I want to insert in the priority queue a pair of elements, how do I so that the queue shows the element with the smallest number and if it…
-
2
votes1
answer126
views.exe has stopped working
Good evening, I wrote a file in c++ but it is no longer working,the code compiles everything right, but if I put to run appears the message that the program stopped working, if anyone can help me I…
c++asked 5 years, 11 months ago Igor Fonseca 21 -
2
votes1
answer73
viewsData Member Initialization Question const
"The 'constancy' of a const object is imposed from the moment the constructor completes the initialization of the object until the destructor of that object is called" - Deitel,++ If the compiler…
-
2
votes1
answer347
viewsUsing "bytes" and "bits"
What use bytes and bits? I’m reading some C and C++ programming books that talk about bytes and I wanted to know what the use is or what these terms are for. For example, this table below talks…
-
2
votes1
answer64
viewsHow to assemble a collection of derived objects, and use specific functions of each?
I want to create a dynamic list that contains all Component derived objects. I’m trying to do it this way: map<string, Componente> tabuleiro_componentes;…
-
2
votes1
answer102
viewsProblems with C++ encryption
I’m making an encryption program that works as follows: It will read a string and then add to each character a respective prime number. Example: a(+2) b(+3) c(+5) d(+7) e(+11) = c e h k p In this…
-
2
votes1
answer559
viewsVisual Studio Character Error
I cannot resolve a character error in Visual Studio. Code 1: #include "pch.h" #include <iostream> #include <cstdlib> #include <clocale> #include <Windows.h> using namespace…
-
2
votes1
answer47
viewsHow to use RAII, Constructors and Exceptions
I’m new to C++ and recently came across something that I can’t quite understand, which is: in my research, I saw that RAII is a suitable technique to be used when you need to acquire a resource in…
-
2
votes2
answers105
viewsTrying to understand c/c++ pointers
Hi guys I’m new to the stack and it’s like this: I’m studying pointers and I made the following code: typedef struct { char nom[256]; int size; float value; }tdados; // criando o tipo tdados com…
-
2
votes0
answers539
viewsWhat is the difference between the infinite loops for(;;) and while(true)?
What is the difference between infinite loops for(;;) and while(true)? Is there any advantage or disadvantage of using one or the other? For example, in a simple terminal input validation code, to…
-
2
votes1
answer106
viewsError searching row inside matrix
The exercise asks me to create matrices to store aircraft registration with some variables, done this, the program asks me to search all the information by entering the code. The problem is that…
-
2
votes3
answers111
views -
2
votes1
answer258
viewsHow to create an intersection with complexity in O(n)?
I need to create a function that makes the intersection between two vectors: vetorA ∩ vetorB and allocates the values found at this intersection in a vetorC! Rules: to) The complexity of the…
-
2
votes5
answers192
viewsCode executes a line that should be conditional
I am doing a job for college at C++ and, when performing an if/Else for a value of totalf equal to or different from 0, it is not obeyed. How do I exit display only a certain printf of correct…
-
2
votes1
answer80
viewsInsertion at the end of the list resulting in 'Segmentation fault'
When implementing a chained list, I found the following problem in the function that inserts nodes at the end of the list: Program Received Signal SIGSEGV, Segmentation fault. 0x000000400d2f in…
c++asked 5 years, 2 months ago Nereu Melo 23 -
2
votes1
answer50
viewsValgrind problem and dynamic allocation in C++
I have a program a little bigger than that, I selected the part that I can not solve, are errors that seem unfounded, I’ve really tried everything. I imagine it’s a structural problem. I will post…
-
2
votes1
answer53
viewsCode ". exe" stopped working
When adding new emails appears the message: project-Email2.exe has stopped working int op = 0, quant = 1; string nomeEmail[quant][2]; while(op != 5){ cout << "Selecione a opção desejada\n[1] -…
-
2
votes1
answer48
viewsWhy does the console even appear using a library to create a window?
I wanted to understand why the console also opens when a program is made using the SDL2 library. I am using codeblocks in windows 10. How do not appear the console and only appear the window…
-
2
votes1
answer88
viewsIncrease multidimensional array size at runtime
Problem: I maintain a 2D multidimensional array that has a dynamic size, is always growing, as I am not allowed to use vector I need to develop a strategy to increase the size of this array at…
-
2
votes1
answer34
viewsConvert Std::vector p/ Std::array implicitly?
How do p/ extend the std::vector so that there is an implicit conversion of std::array for std::vector? Imagine I have this: template <class T, int N> std::array<T, N> vector_to_array…
c++asked 4 years, 9 months ago Daniel Falbel 12,504 -
2
votes1
answer161
viewsHow to accurately measure the run time of a function in C++
I am doing a college job and need to measure the run time of a recursive function, but when I do the measurement in nanoseconds most of my data comes back zeroed. Is there any way to do a more…
-
2
votes1
answer73
viewsHow to call the constructor within a method
I have a simple college exercise to mess with the vector. Basically these are the actions that we should do: cout << "\tMexendo com Vetor\n"; cout << "\n\nEscolha uma das opcoes para…
-
2
votes1
answer146
viewsReference not defined in compiling an executable for windows x86
I’m building a scaffold project for cross-Compile on c/c++ for Windows, Linux, Mac, Ios and Android. When I compile the project for Windows x86 and I have a very strange error, but the same code…
-
2
votes3
answers1489
views -
2
votes3
answers109
viewsCalculator does not print the correct value
Hi, I’m coming back to the C language after a while. I’ve always used Code :: Blocks, but now, I migrated to Vscode. When I try to print values, giant numbers come out, for example: n°1 = 15 and n°2…
-
2
votes2
answers259
viewsInvoke child class method in C++
I have a parent class/structure and a daughter class/structure in C++. The parent class defines a method, and the daughter class burdens that method. Trivial example: struct Pai { void imprimir() {…
-
2
votes2
answers231
viewssizeof does not work to determine the size of malloc
Well, I was doing a data structure job when I came across the need to dynamically allocate a vector, however, even allocating the space needed for the structure, the value returned by sizeof is…
-
2
votes1
answer84
viewsHow to resignify bytes without Undefined behavior?
Details In Assembly, C, C++, C# with unsafe and other languages it is possible to reinterpret binary code at the address as of different type from the original. Convert type int* for float* in C,…