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
-
8
votes2
answers332
viewsHow does the computer "know" the alphabetical order when comparing two chars?
I have a question about Caesar’s cipher program: #include<iostream> #include<string.h> using namespace std; int main() { cout<<"Enter the message:\n"; char msg[100];…
-
7
votes4
answers1099
viewsWhen to implement header functions?
I usually divide the program into small modules, each with its own header and implementation. In general, the abstraction level used allows the implementation to be completely changed without…
-
7
votes1
answer2547
viewsWhen to use void* and auto*?
C++11 provided us with the type auto (Automatic). It can transfer type for the first time. But before it, people used to use the void*, where you referenced on the pointer. I still use void*…
-
7
votes3
answers1538
viewsDisplay from 1 to 1000 in C++ without using a semicolon
Make a program in C++ that displays on the screen the numbers from 1 until 1000, counting with these two, but without using the semicolon. I already made a sketch here but I have to choose between…
-
7
votes2
answers1318
viewsCalling C++ from Javascript?
I have a simulation in C++. I passed this simulation to Javascript so that the user could play with it in the browser, but it became much slower. If possible, therefore, I would like to call the…
-
7
votes1
answer169
viewsHow to fix rigid "bodies" using Physx
How can I fix two rigid or dynamic "bodies" in a way that where one goes the other goes together as fixed as possible with Physx. I’m using the class PxFixedJoint but I didn’t like it. As you can…
-
7
votes2
answers1444
viewsHow to organize code without losing performance?
Using functions instead of putting code directly influences a program’s performance ? For example: void minhafuncao(){ printf("Funcao"); } main(){ minhafuncao(); } in place of main(){…
-
7
votes1
answer2796
viewsWhat are Macros and how to use them?
So far during my C programming course, the only contact I had with macros came from standard libraries and not really knowing what was going on when calling these macros. I would like to know…
-
7
votes2
answers4418
viewsWhat does it mean to create an object with that asterisk?
Although I knew programming for a reasonable time, learning C++ with QT, I came across something I hadn’t seen in other languages. I noticed that some objects (not all) need to be created with an…
-
7
votes2
answers111
viewsAccess to specific memory points
How do I access an exact address in memory on Windows? unsigned char * mem = {??};
-
7
votes3
answers31930
viewsMake an algorithm to calculate the number of days elapsed between two dates in c++
Guys I have this algorithm: Make an algorithm to calculate the number of days elapsed between two dates (also consider the occurrence of leap years), knowing that: a) each pair of dates is read on a…
-
7
votes2
answers6202
viewsHow does the C++ layer work on the Web system?
I see that many complex web systems say in their "API" that they use C++ as the "lower" layer, I don’t know if the question is too wide, but briefly I believe it is possible to explain to me how…
-
7
votes1
answer5408
views -
7
votes1
answer711
viewsHow does the class constructor statement in Qt work?
I work with C and a little bit of Assembly, in Atmel AVR microcontrollers. I’m trying to understand how the framework Qt extends C++. I created a new project with Qt Creator (Widgets), and generated…
-
7
votes3
answers972
views -
7
votes2
answers745
viewsSet values or not in c++variables
Good night. Should I or should I not set values in variables when creating them in c++? An example: int x = 0; int y; What’s the difference in these two cases? And what happens in memory when I…
-
7
votes3
answers1492
viewsWhile repeating structure to recalculate in C
I solved this exercise below and thought about putting a structure while repeat, for the person to calculate again. But when I put’s' to return and calculate again, the exercise sums up the values…
-
7
votes1
answer521
viewsWhat are the advantages of using directives and macros?
Directives and macros influence program performance?
-
7
votes1
answer1284
viewsCin vs scanf, which is faster?
In competitive programming it is common for several programmers to use scanf() and printf() in C++ code instead of using cin and cout. And I’ve even seen problems that result in a Time Limit…
-
7
votes2
answers169
viewsRecursive code C++
I have the following iterative function: int getNumPastasColididas(int i){ int c = 0; for(int i = 0; i < size; i++) c += table[i].hasColided; return c; // c = 89832 } I tried to play the function…
-
7
votes2
answers616
viewsHow do I make my C++ programs multi-architecture (32 and 64 bit)?
Developing a native C++ application using Devcpp and the Mingw compiler, when running the application on another machine I noticed an error regarding the architecture, because my program only runs…
-
7
votes3
answers23806
viewsSize of a String
A char in the C language occupies 1 byte in memory. Ex: char ch;//a variável ch esta ocupando 1 byte na memória And a vector of char best known for string, its size in bytes will be counted…
-
7
votes1
answer131
viewsHow to dynamically insert into an Std::array?
I’m migrating from C to C++ language, and I want to stop using traditional C language means, like the C vector. It is possible using the std::array insert elements dynamically as in std::vector?…
-
7
votes1
answer1855
viewsWhy use const after function?
I noticed some codes from other C++ programmers that use functions like: bool CClass::isRunning() const { return this->_running; } I understood that in this way it is not possible to modify any…
-
7
votes2
answers225
viewsProblems with sizeof
I’m trying to get back the size of array, but it’s making a mistake. What to do? #include <stdio.h> char *palavra[] = {"casa", "carro"}; int main(){ int i; for(i = 0;i <…
-
7
votes2
answers362
viewsHow to pass an array as argument of a function per copy?
Like we know a array is used as a pointer in various situations. A parameter that waits for a array is actually a pointer, so what you copy is the memory address and not the data from array, is a…
-
7
votes2
answers1882
viewsHow to convert a text to number?
How should I convert a text that I know is an entire number coming externally? It would be something like a ToInt() or something like that.
-
7
votes2
answers10403
viewsHow to separate a string into pieces?
In other languages there is split, explode or something like that string in pieces according to some separator. There is something ready in C or I have to do in hand?…
-
7
votes1
answer3111
viewsWhat good is an Inker?
Some languages use a Linker or likeditor as it is also called. What is its function and its relation to the compiler? Why some languages do not have a Linker?…
-
7
votes1
answer304
viewsIs it correct, following object orientation, to use pointers to C++ functions?
I am creating classes that represent items in a menu, each item performs an action and I am assigning the action by a function pointer to each instantiated menu item, is this valid by following POO?…
-
7
votes1
answer514
viewsIs there any project organization standard for C++?
In Java and Actionscript3.0 we use namespaces based by directory path, I see much use of namespace, but are not based on the "location" path of the class in the folder. I searched a lot if there was…
-
7
votes1
answer2667
viewsHow does it work to use a vector of type struct ? (C++)
I would like help to understand how it works to declare a vector of type struct. In the example of the code below I create the struct configcarros and I would like to create a vector of the type of…
-
7
votes1
answer144
viewsThe __fastcall, necessary or not?
What is the usefulness of using __fastcall in the C function call++?
-
7
votes3
answers145
viewsHow to embed one library into the other?
I have created a C++ game development library. Only my library needs another to display the images on the screen, the SDL2. So every time someone wants to use my library, they would have to link to…
-
7
votes2
answers1064
viewsLambda functions in C++, when to use and what are the advantages?
When choosing to use a lambda function or a normal function, and what is the advantage of using a lambda function compared to a normal function? There is the call price of a function in a lambda…
-
7
votes1
answer4999
viewsWhen to use Cin.ignore() in C++?
When exactly to use the cin.ignore() in a software written in C++? Why many of the times, when I’m making a big software, the readings keep bugging, sometimes if I put cin.ignore() Loosens,…
c++asked 6 years, 3 months ago Victor OCV 393 -
7
votes1
answer1877
viewsWhat is using namespace?
Since the beginning of my C++ learning I have been told to use the namespace std, not to spend all the time using the std::cout. But after studying more about language, I learned that :: is a target…
-
7
votes1
answer121
viewsWhat is the "slicing phenomenon" when trying to read data from a heterogeneous array?
I was curiously reading a reply on how to store heterogeneous types in an array when I come across the following response snippet: You will have to store in each element of the vector the object and…
-
7
votes1
answer2353
viewsAnalyze whether a number is even or odd
The program must do: Digite um Número: 12345 1 e ímpar 2 e par 3 e ímpar 4 e pra 5 e ímpar So far I’ve made the following code: void parImpar (int num) { int resto; while (num > 0) { resto =…
-
7
votes1
answer85
viewsHow is it possible for the same memory address to have 2 different values at the same time?
I had a question about the behavior of the type qualifier const of the C++. I was testing how much a variable declared as a constant is protected from changes. For this I tried to change its value…
-
6
votes2
answers654
viewsPointer logic
In C++, you can do the following: int variavel[10][10]; int** variavel; But when I want to create an array 2d, where I can have the first part "unlimited" and the second part with limit? tipo…
-
6
votes1
answer197
viewsDisplay a dynamically loaded text/photo pad with QML for Android
I’m writing an app using the newly released Qt 5.2 QML for Android. On one of the screens I need to display an article that is loaded from a server and may change after the launch of the…
-
6
votes3
answers3071
viewsDoes anyone know how to insert names in alphabetical order into a c++ vector?
I made this code but it doesn’t work right, it inserts in alphabetical order backwards. void inserirNomeNaLista(vector<string> &lista) { vector<string>::iterator itr; string nome;…
-
6
votes3
answers5076
viewsHow to pick up the arrow keys in C/C++?
Is it possible to pick up the arrow keys (famous arrow keys) from the keyboard? if yes, how?
-
6
votes4
answers1095
viewsWhy can’t I release memory?
I have the following code: #include "iostream" int main(){ int* A = new int[4]; int* B = A; delete[] A; delete B; if(B == NULL) std::cout << "B = NULL" << std::endl; else std::cout…
-
6
votes3
answers1655
viewsHow to verify which technologies the CPU supports at runtime?
I am writing a program for PC that has optimized function calls for SSE2, SSE3 and maybe SSE4. However, I cannot guarantee that the PC running the program supports these technologies and would like…
-
6
votes4
answers11111
viewsConverting float to char array in C/C++
I recently took a test and there was a question that asked for a number like 123.456 was shown as 321.456. I thought the best solution would be to convert this to an array of char and then create an…
-
6
votes1
answer234
viewsHow to use a Lua variable in C++?
I can’t get value from a Lua matrix to use in C++. So I take the value of the variable M: //No LUA M = 85 //No C++ L = lua_open(); luaL_loadfile(L, "teste.lua"); lua_pcall(L, 0, 0, 0); int m;…
-
6
votes1
answer850
viewsHow to "call" a function from a Lua table in C++
I’m trying to "call" a function of a table written in Lua. The problem is that I’m not managing to pass three arguments to this function. When I pass the arguments, it’s as if the Lua skip the first…
-
6
votes1
answer1411
viewsHow to place variables within vectors?
How do I create variables within a vector? Something like: int arr[] = {int x=1, int y = 2};