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
-
13
votes4
answers4494
views -
13
votes1
answer816
viewsHow to make an excellent C++ program without C traces?
As a beginner in C++ I asked some questions here and was warned a few times by @Maniero that what I was doing was C and not C++. The problem is that C++ allows us to use many things similar to C. So…
-
12
votes2
answers4009
viewsFormat decimal with comma and thousand with dot
How can I format a float for the Brazilian value format(price)? Example: in php number_format($float,2,',','.') separates decimal with comma and unit of thousand with dot.…
-
12
votes4
answers8023
viewsWhen to use size_t?
Already research on the subject, but I always end up getting confused. I found a article in English that explains very well some reasons for the existence of the type and how to use it. According to…
-
12
votes2
answers955
viewsPutting a background color after recognizing and cropping people’s faces
I found a tutorial of an app that recognizes the face of people using the camera and creates a rectangle around the recognized face. - (void)processImage:(Mat&)image; { Mat grayscaleFrame;…
-
12
votes2
answers965
viewsIs there any way to run a java program (.jar) from a C or C++ program?
I wonder if there’s a way I can write a program .jar, and write a C/C++ program that called the JVM to run the file .jar. Is it possible? If so, can you give me an example of code or an instruction…
-
12
votes2
answers5293
viewsWhat is an Iterator?
Studying the STL in C++, I almost always come across the term iterator, example: std::vector<int>::iterator it; What is the function of a iterator?…
-
12
votes1
answer1550
viewsWhy can’t you declare a variable within a case?
Why don’t you compile? #include <stdio.h> int main(void) { int valor = 0; scanf("%d", &valor); switch (valor) { case 0: int variavel = 1; printf("%d", variavel); break; default: int…
-
12
votes1
answer9161
viewsWhat is Segmentation fault?
This error often occurs in code with problems. I don’t see it occurring in other languages. Why does it occur? What does it mean?
-
12
votes1
answer218
viewsHow does "free()" know how much memory it has to release?
When we use the malloc() we say how many bytes we need. But free() we do not say. How he knows how much he needs to be released?
-
12
votes1
answer1922
views -
12
votes2
answers688
viewsClass copy in C#
In C++ programming to copy one class, to another, just do the following: minhaClasse* class_1 = new minhaClasse(); minhaClasse* class_2 = new minhaClasse(); *class_2 = *class_1; // Faz a atribução…
-
12
votes0
answers192
viewsHow to write programs that support internationalization using cmake?
I am writing a small software in c++ and I would like to be able to translate it into other languages. Looking quickly over the internet the most accepted tool in linux environments is the GNU…
-
11
votes4
answers152
viewsIs a compiler allowed to omit a reference member in a class?
Consider the following class: struct Type { int a, b, c; int& ref; Type(int m) : a(m), b(m), c(m), ref(a) { } Type(const Type& ot) : a(ot.a), b(ot.b), c(ot.c), ref(a) { } } obj; Here we have…
-
11
votes4
answers584
viewsHow to verify the efficiency of these 2 functions in C++?
How to determine the best choice between these two functions for implementation? 1: int X(int x){ if(x<=0) return 0; return(x + X(x-1)); } 2: int Y(int x){ int soma=0; for(int i=0;i<=x;++i)…
-
11
votes2
answers299
viewsC operator precedence table
In C why y = (y=2 , y+3) returns 5 if the + has priority over = and the ,?
-
11
votes1
answer603
viewsVariable within a class pointer
I have several header files with GUI management functions that I’ve done to create windows, similar to those libraries like GTK, QT and others, and I’m turning them into library, but I’m having a…
-
11
votes3
answers5893
viewsWhat is operator overload?
In some programming languages such as C++ it is possible to overload operators. What is and what serves?
-
11
votes1
answer360
viewsHow to get information from a . CPL?
I wanted to make a program that would display all the items on the control panel. For this I need to consult some registry keys, but there are programs that still use cpl files to store the…
-
11
votes1
answer172
viewsDifficulties with selecting items in a Qtreeview
Setting: I have an application that manages a list of images of human faces with prototypical emotional expressions. I created a class inherited from QAbstractListModel to provide the model (model)…
-
11
votes2
answers1324
viewsHow to use Template in C++?
I’m learning a little about template and made an example, but when I went to apply to my project I couldn’t, let’s go to the following test: #include <iostream> using namespace std; template…
-
11
votes2
answers1560
viewsHow to create an aquivo. h?
What good is a arquivo.h and what improvement it brings to the program in C++?
-
11
votes1
answer143
viewsWhat does " " mean in the header of C++?
I was looking at the MFC header and I don’t know what the character " " means in this context: #define BEGIN_MESSAGE_MAP(theClass, baseClass) \ PTM_WARNING_DISABLE \
-
11
votes1
answer385
viewsIs the C# language recommended to be distributed online with a database?
It is very easy to get the entire code of a C# program using . NET Reflector. Would it be possible for me to put the same security in a C# program a program made in C++? I found that answer no Stack…
-
11
votes1
answer127
viewsQvideowidget displays nothing
I’m trying to use the classes QMediaPlayer and QVideoWidget to display a video on a system I’m producing. Only these class rays don’t work as expected. The QVideoWidget just doesn’t show up, doesn’t…
-
11
votes2
answers1385
viewsWhen to use "inline"?
Everybody says you don’t have to use inline functions since the compiler knows what to do better than the programmer. But if it has in the language it should serve for something. Is it useful in any…
-
11
votes3
answers586
viewsWhat does the 3-bar C++ comment mean?
I know there are basically 2 types of comments, those of a line // and the multilines /* */, however if I comment with 3 bars until the color of the comment changes, for example below Qt and Visual…
c++asked 5 years, 11 months ago Samuel Ives 1,676 -
11
votes3
answers485
viewsC++ - What’s the difference of using fixed C++ and typedef types of a type?
A few days ago studying about emulation I came across a question in the English stack overflow about CHIP8 emulation, and one of the answers said not to use C arrays as for example int i[12] instead…
-
10
votes2
answers6412
viewsWhat is the C++ copy builder for? How do I implement it?
I am a programmer Java and I am currently studying C++. In addition to the "normal" constructors (the standard constructor and the parameterized), C++ has a copy builder. I would like to know what…
-
10
votes2
answers455
viewsWhat is the best alternative: define, enums or variables?
Recently, in a project where I have to declare many counts, I came to this doubt. Which is the best option define's, enum's or constant variables? At first I think to use enum is the best…
c++asked 10 years, 9 months ago Lucas Lima 6,714 -
10
votes1
answer5452
viewsBasic image editing using Opencv
Hello, I’m learning to use the features that Opencv offers for image processing and the following question has arisen: How do I edit only a predetermined area of an image? To facilitate the…
-
10
votes2
answers517
viewsHow does Std::move work?
I would like to understand the operation of std::move. I realized that with the C++11 specification comes this new function, as well as now we have a new operator (&&). What is the semantics…
-
10
votes2
answers57301
viewsHow to limit decimal places?
I have a question, it has to limit the number of decimal places in C++? float x = 2.958; Instead of rounding up or down using floorf, roundf, can only take the two numbers after the comma? that…
-
10
votes2
answers1800
viewsCan I use "Cin" and "getline" in the same code?
I was fixing the white space problem with the getline only that I came across this problem where the question "Type the employee name:" is skipped, how to solve this? Is it because I’m using cin and…
c++asked 8 years, 11 months ago Marcelo T. Cortes 804 -
10
votes1
answer2100
viewsDifference between Std::list, Std::vector and Std:array
All are containers used for data guards in a sequential manner, but what are the main differences between them?
-
10
votes2
answers3616
viewsWhat is the difference between a file . c and . cpp?
C and C++ are two different languages, however C++ is a "superset" or superconpin of the C language. So what is the difference between a file with the .c and .cpp?…
-
10
votes3
answers302
viewsWhat is the cost of calling many functions?
Recently, faced with a discussion about Clean Code and programming best practices, a co-worker commented that in his previous job he had a lot of resistance on the part of the other programmers to…
-
10
votes3
answers540
viewsWhat kind of smart pointer to choose?
How to know what kind of smart pointer to use? And what’s the difference between them? Example: std::unique_ptr<MinhaClasse> mClasse(new MinhaClasse) std::shared_ptr<MinhaClasse>…
-
10
votes2
answers930
viewsPrototype functions in C/C++
What kinds of functions are these? What can these prototypes do? /*1*/int func ( int (*x)(int,int) ) /*2*/int func ( int x(int,int) ) /*3*/int func1 ( int(fn)() ) /*4*/int func2 ( int(*fn)() ) Is…
-
10
votes1
answer766
viewsTo learn C++ is it necessary to learn C?
In case I want to learn about C++ I need to learn C before or they are different?
-
10
votes1
answer451
viewsWhat is Std in C++?
I’m learning C++ and I see std being using everywhere. What is this std? He’s like a library or something different than that?
-
10
votes1
answer195
viewsCreate a resizable window
Hello, I was able to create a console window that does not show scrollbars: CONSOLE_SCREEN_BUFFER_INFO csbi; int columns, rows; COORD size; COORD BufSize; while(TRUE) { size =…
-
10
votes3
answers685
viewsPrevent the CMD command interpreter from using the operators passed via parameter/argument?
There is a way to prevent operators present in past arguments, via command line, from being used/interpreted by the interpreter CMD in C, C++ or C#? I want to make use of characters present in the…
-
9
votes3
answers308
viewsHow to "create" a variable in "Runtime"?
I’m doing a project that implements a Python-style console. It has several functions, it has many things. But I need to implement a command called set. set declare a character string and define its…
-
9
votes2
answers185
viewsHow to make an IO "equivalence" in Java and C++?
I made the following code in C++: #include <iostream> template <typename type> class Foo { public: Foo(type FooTest) { std::cout << "Foo " << FooTest; } }; int main { new…
-
9
votes2
answers4823
viewsHow to access a specific RAM location by address?
I’m starting to study C/C++ pointers and it was something that caught my attention by the robustness and the range of possibilities. However, I can only access memory positions by assigning to my…
-
9
votes2
answers990
viewsHow to verify collision between particles?
I need to know how to make each circle collide with each other along with the part of how I’m going to go in such a direction after this collision. This is the class of the main program window:…
-
9
votes1
answer261
viewsOptimize the collision between particles
I need to optimize as much as possible the algorithm that makes the particles collide, is there anything that can be done to do that? And I also want to add a background image, it’s possible?…
-
9
votes1
answer216
viewsPointer variable is declared null, but member function performs normally
Below follows an example of the code I’m trying to execute. //main.cpp #include <iostream> using namespace std; class A{ public: A(){} ~A(){} void teste(){ cout << "Teste" << endl;…
-
9
votes3
answers1348
viewsProblems with "or" in C++
I need to make an algorithm that gets 3 different numbers, and if it gets repeated numbers, it gives an error message. My program is all working properly, but when I put such a line to warn of the…