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
-
82
votes5
answers17889
viewsWhy choose C instead of C++ or C++ instead of C?
I think everyone with the least amount of knowledge knows when to choose C or C++ over other languages. There are clear cases where these languages are more suitable and others that do not make so…
-
59
votes3
answers6039
viewsWhat’s the difference between DLL and lib?
I know that .dll and .lib are libraries, the first is dynamic and the second is static. But what does it really mean? How does each one work? If I have to generate a library from a code, what I…
-
48
votes3
answers24523
views -
38
votes3
answers2673
viewsHow to make "case-insensitive" comparisons in Sqlite?
Since there’s an obsession with accent questions, here goes mine :) Sqlite allows direct comparisons or through like with any encoding/charset as long as it’s done byte to byte. It only allows…
-
38
votes2
answers1031
viewsWhy use "while(0)"?
In Linux code I saw some macros with: do { }while(0) Is there a reason? Because there seems to be no logic in a repeat loop where the code repeats only once.
-
34
votes7
answers14277
viewsWhat can C++ do that C# can’t?
Being a programmer . Net but with an old passion for C++ (which has grown since C++11), I was with this curiosity. I know . Net can be "extended" with C++/CLI, but I would like to know what C# pure…
-
25
votes2
answers4341
viewsWhat are rvalues, lvalues, xvalues, glvalues and prvalues?
Prior to C++11 there were only two value categories for expression tree types: lvalue and woodland. Quite simply, the first represents a reference that can be changed and whose address can be read,…
-
25
votes2
answers1393
viewsWhen should I choose whether or not to use a pointer when creating an object?
In C++, I’m used to seeing objects being created through the operator new, which is when the object is referenced by a pointer, thus: MinhaClasse *mc1 = new MinhaClasse(); This form seems to me the…
-
25
votes3
answers2778
viewsWhat is the purpose of "continue" in C?
int main () { /* local variable definition */ int a = 10; /* do loop execution */ do { if( a == 15) { /* skip the iteration */ a = a + 1; continue; } printf("value of a: %d\n", a); a++; }while( a…
-
24
votes3
answers1024
viewsShould I free up all the allocated memory when finishing a program?
It is commonly accepted that when I allocate a block of memory I am responsible for releasing it. This is particularly true when programming based on RAII. However the following program works…
-
23
votes2
answers1963
viewsWhat is the purpose of the free() function?
In which cases should it be used? There is an alternative? It is recommended to use?
-
23
votes1
answer9539
viewsWhat is the difference between "calloc()" and "malloc()"?
What the function calloc() makes the malloc() Doesn’t it? Why is it hardly used?
-
22
votes3
answers1767
viewsWhat prevents an array from being initialized with a variable size in C?
Why does an array need to have a constant size? What prevents it from having a variable size?
-
20
votes2
answers1354
viewsIn which situations should I dynamically allocate a vector to C++?
I’m fiddling with a code from a framework for my work. In one of the functions, it dynamically allocates a std::vector, makes a copy of each node the object has and returns it to the user:…
-
20
votes3
answers4153
viewsWhy are local variables avoided in Arduino?
In several code examples for the Arduino I note that there is almost no use of variables in local scope. One of the examples present in the IDE: Analog > AnalogInput: int sensorPin = A0; int…
-
20
votes4
answers6387
views -
20
votes3
answers10053
viewsWhy is it not good practice to use namespace "Std" in C++?
I was using using namespace (nomeDaBiblioteca); in my code and ended up having some conflicts with another library. Why these conflicts happen and what is the best solution?…
-
20
votes2
answers540
views+ 3 overloads - What would that be?
In some functions appears such a quantity of overloads, That means the higher that number, the slower it is? Note: I used tag C++ and C# why I saw these overloads in these languages. Microsoft…
-
20
votes2
answers13387
viewsWhat is the difference between "NULL", "0" and 0?
Both are worth zero. I can use the 3 interchangeably always?
-
19
votes2
answers1037
viewsHow to use Qt translations directly with Qapplication::tr()
In an application developed in Qt I have a non-visual class (i.e., that is not inherited from a QWidget) but that handles text strings that must be presented to the user. To use the Qt translation…
-
19
votes1
answer941
viewsHow does C/C++ "padding work?
In several responses here at Stackoverflow I have noticed users commenting on padding in data structures. struct { int a; char b; float d; } What is this one padding (filling) that exists between…
-
19
votes1
answer739
viewsWhat is the difference between "Generics" (Java/C#) and "template" (C++)
In the question What are the differences between Generic Types in C# and Java? the difference between the Generics between Java and C#. We know that C++ does not have Generics, but uses templates…
-
19
votes5
answers5742
viewsIs it possible to develop websites with C/C++?
I know a little bit of PHP, but I see that on content sites, sometimes it gives a crashes and etc. Researching, I saw reports (very superficial) that it is possible to develop web applications with…
-
18
votes3
answers18194
viewsWhat purpose of unsigned in C++
What is the purpose of unsigned in the C++? Example: unsigned char ch2;
-
18
votes1
answer289
viewsBuild C++ using Gradle
The Gradle and a great ally in java and android development. I was looking at the site and realized that it can also manage projects in c++. How can I use it to compile a super simple project (hello…
-
18
votes1
answer467
viewsAre there alternatives for reflection/introspection in C++?
I have the following problem. Given some kind of a guy T: template <typename T> I need to be able to convert an object like T on a map std::unordered_map<std::string, boost::any>…
-
17
votes5
answers453
viewsIs it legal to delete this in a member function?
The language delete this serves for an object to commit suicide. For example: void Recurso::release() { --refs; if (refs == 0) delete this; // Aqui o 'this' pode ser um ponteiro inválido, // tocar o…
-
17
votes1
answer484
viewsData access performance in heap and stack and object allocation
Data access in the stack is faster than in heap? And why allocate an object to heap?
-
16
votes1
answer673
viewsDoes compiling on your computer really improve performance?
Any programmer knows that when building a C/C++, the compiler can optimize the code to generate faster executables. But, it is also said that there is the compiler optimization for your processor.…
-
16
votes2
answers3148
viewsWhy does everyone hate multiple inheritance in C++ and what’s your difference to mixins?
I’ve always heard that multiple inheritance in C++ is chaos. Why? It wouldn’t be technically the same thing as using mixins in languages such as Ruby? And what is this abstract class of Java? It’s a…
-
16
votes3
answers3377
viewsHow does the MVC framework for Desktop applications work?
I have seen many web projects like php frameworks, Asp.net, however I read in some places that MVC came before the web, it was aimed at developing desktop applications, however I did not find…
c++ mvc pattern-design software-architecture software-engineeringasked 9 years, 2 months ago Guilherme Nascimento 98,651 -
16
votes2
answers2560
viewsFork in Windows
There is something in Windows like (or some alternative similar to) fork of the POSIX (UNIX and Mac) systems to create a child process that is an exact copy of the parent and runs from the call…
-
16
votes1
answer677
viewsWhat is undefined behavior, unspecified and defined by implementation?
What is the difference between the three terms "undefined behavior", "unspecified behavior" and "behavior defined by implementation"? Why do they exist in these forms?
-
15
votes1
answer205
viewsWaiting for a signal within a Qquickimageprovider
I’m creating an application using QML and the Qt 5.2. In her a ListView displays multiple items, each with an image and associated text. The image is built based on data uploaded from a server by…
-
15
votes2
answers921
viewsWhat is the use of pointers?
What is the use of pointer pointers, example: int var; int *p; int **pp; var = 50; I even understand the use of the simple pointer(*), but why use another pointer to reference this?…
c++asked 10 years, 4 months ago Weslley C X Sardinha 1,427 -
15
votes4
answers6237
viewsHow does the "#include" directive work?
C++ "include" does what exactly? I know it "matters" a header/library. But if I have a Header. h com: #include <string> using namespace std; string a() { return "PTSO"; } and on Main.cpp:…
-
15
votes2
answers1239
viewsWhat is the difference between *var++ and *var += 1?
I’m writing a feature with the signature: int increment(int *val). My intention is to receive an entire pointer, increase its value in 1 and return that value. The body of my function was as…
-
15
votes2
answers458
viewsIs there a way to create cross Platform programs in C++?
I know how to program in C and I am now learning Java, but I would love to learn C++ and I wanted to know if it is possible to create programs cross Platform, that is, that they run in any OS…
-
15
votes1
answer311
viewsHow does the switch work behind the scenes?
Seeing those comments on the use of switch is the doubt how it really works and why it is different from the if when only buy for the equality of a single variable against a sequence of values. How…
-
15
votes1
answer170
viewsWhat is the use of "= delete" in the declaration of a constructor in C++?
I came across a builder declared as follows: State(const State& em) = delete; Does anyone know what the = delete at the end of the signature of the manufacturer?…
-
14
votes2
answers23232
views -
14
votes1
answer5442
viewsWhat is big-endian and what is the difference to little-endian?
I have a basic notion of what the big-endian and the little-endian are, but I cannot see exactly how the different form of storage can complicate portability. What portability problem occurs due to…
-
14
votes1
answer37459
viewsWhat is the meaning of the word "Cout" in C/C++?
Well, it is very common in programming languages to have responsible keywords for printing data output. Some are classic like echo, print, printf and write, etc.. But in the C/C++ we have the cout.…
-
14
votes5
answers13398
views -
14
votes2
answers2384
viewschar[] or *char malloc?
What difference in C between char text[10] or char *char = (char *)malloc(10*sizeof(char)); What advantage of using malloc on a pointer?…
-
14
votes2
answers2381
viewsWhat is the difference between static and dynamic linkage?
Recently, searching why small Go codes have a much larger executable than the same C-generated code, I read an answer stating that the reason is because Go use linkage static, unlike C, which uses…
-
14
votes2
answers128
viewsWhat are they and when to use Anonymous Unions?
During the data structure book reading, it was briefly presented the concept of anonymous unions, which would be the definition of a union without specifying a label (name). However, I did not…
-
13
votes8
answers59138
viewsHow to raise a number to a power without using the Math. h library?
How can I raise a number to a power without using the library math.h? Example: potencia = x ^ 1/2; How do I do it in c++?
-
13
votes2
answers2414
views#pragma Once or #ifndef?
I know there are two ways to prevent a header file from being duplicated in C C++: #ifndef FOO_H_INCLUDED #define FOO_H_INCLUDED class Foo { // código }; #endif And #pragma once class Foo { //…
-
13
votes2
answers7627
viewsWhat is the C/C++ volatile modifier for?
I’ve seen in some codes on C/C++ statements like this: volatile int i = 0; I would like to know what the modifier is for volatile and in which cases should I use it.…