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
-
6
votes1
answer472
viewsHow to reduce the spacing between printed characters with t in C++?
I wanted to place the columns closer so that it doesn’t happen as in figure 2. int i,j,elemento; for(i=0; i<elemento; i++){ for(j=-elemento; j<=elemento; j++){ if(i >= abs(j)) {…
-
6
votes3
answers144
viewsType declaration in parentheses
I am porting an application done in c to C++ and found the following function statement: set_funcao(0, (double)pow((double)2, 32) ); What does the type in parentheses mean? It is the type of return…
-
6
votes1
answer102
viewsHow does Visual Studio’s Edit and Continue work?
Visual Studio allows you to edit C#, VB.NET or C++ code in debug when you hit a breakpoint or click the break button (pause icon). The name of the tool is Edit and Continue. According to the…
-
6
votes1
answer169
viewsIntelligent Pointers
I was studying smart pointers and based on this blog: https://murilo.wordpress.com/2008/12/15/smart-pointers-os-ponteiros-espertos-do-c/ #include <iostream> template <class T> class…
-
6
votes2
answers165
views -
6
votes1
answer85
viewsShould I avoid operations between constants in a loop?
In C++ there is some sort of optimization or cache that prevents the same mathematical operation between constants to be repeated, mainly in loops, thus decreasing application performance? For…
-
5
votes3
answers457
viewsLock the window zoom
How can I block the window rise QDialog and QWidget? For example, in the Skype login window you cannot enlarge the window.
-
5
votes1
answer57581
viewsHow to use mod in C C++?
how do I use the MOD function in C C++? (N MOD 2) = 0 I have to use this line of my code.
-
5
votes2
answers259
viewsRemoval of repeated values
I have two Vectors, each with coordinates (x,y). I need to reverse the second vector, getting with (y, x) and merging with the first, but I can’t get repeat in the first field, so I thought I’d use…
-
5
votes1
answer445
viewsHow to apply/search for global/local transformations in Opengl
I am programming a simple Game Engine using the graphical API Opengl. But I have a problem that I can’t solve. The problem is that the transformations in world (world) do not work properly. The…
-
5
votes3
answers1021
viewsIterated inline functions
In several articles, I read that adding an inline function within an iteration(while,for) generates an unnecessary consumption of system resources. Write down: #include <iostream> inline int…
c++asked 10 years, 3 months ago Weslley C X Sardinha 1,427 -
5
votes2
answers592
viewsHow to convert a Std::string to a Qstring?
I’m trying to make a simple dialog box display my name. See the code. Pessoa *p = new Pessoa("Ronald Araújo", "[email protected]", 23); QMessageBox msg;…
-
5
votes3
answers8270
viewsConvert natural number to binary recursively
How can I turn this function into a recursive function? I managed to make it iterative in this way: #include <iostream> using namespace std; int main (){ int n,pot,bin; cout << endl…
-
5
votes3
answers2379
viewsHow to see how much memory occupies such a variable in C++? And how to use the define?
How to see how much memory occupies such a type variable int, char e long in the C++? And how to use the #define?
-
5
votes1
answer518
viewsSending characters through the serial port including zero-value bytes
I am making an application in which I need to send a character array via serial to an external hardware (declared as unsigned char) containing commands and times. With the commands I have no…
-
5
votes3
answers389
viewsCompiler error when trying to reset vector
Compilers error when I try to reset an array with the command vetor[10] = {0}; And he only makes a mistake in that line because I also used it in the assignment int vetor[10] = {0} and there does…
-
5
votes3
answers185
viewsProblem with program that prints three numbers increasingly
I’m having trouble creating the decision structures in a program that reads three numbers and prints them increasingly. My code that’s going wrong is this:: #include <stdio.h> int main (void)…
-
5
votes2
answers887
viewsCheck if variable has been set
How do I check if a variable has been set? The #ifndef can be used for this? Plainer: #include <iostream> int getNumber() { if (check) { check = false; return 10; } else { bool check = true;…
-
5
votes3
answers557
viewsUnsigned int doesn’t work?
Next, my program keeps compiling even after I have assigned a negative value to an unsigned variable, why does this happen? I use IDE Code::Blocks 13.12 unsigned int numero1 = -1;…
-
5
votes1
answer3306
viewsHow to create a new library in C++
I would like to know how to create a new library in C++. if one can give an example, it can be a widespread example.
-
5
votes1
answer214
viewsHow to use qtwebkit-plugins in my project?
Qtwebkit-plugins is a library that provides functionalities for QWebView, as SpellCheck/Corretor ortografico and Notification Web API. Read about in: SpellCheck Notification Web API I tried to…
-
5
votes1
answer1927
viewsBuild GUI for Windows without using Windows API
I have been searching the internet for a way to build graphical interfaces for windows without necessarily using Windows API. I program in C# and for this, I have as solution WPF. However, I could…
-
5
votes1
answer1602
viewsChar vector cast for pointer
People how a cast works in a vector char for a pointer int? for example: char vetor[2]; int *p; p = (int *)&vetor; Can someone explain me this line?…
-
5
votes2
answers661
viewsWhere to create macros in C?
In terms of good programming practices, if I want to create a macro, for example, a macro that has about 30 lines of code, I should implement it in the archive .c or in the .h? What is good…
-
5
votes1
answer819
viewsHow does "printf()" work?
How the code works behind the function printf() do C? I am aware of what this function does, I want to know how it does.
-
5
votes2
answers214
viewsMake a reference variable point to another variable
I have the following question, for example: int a = 5; int b = 10; int & r = a; How do I use the reference variable r point to b and no longer to a? It is possible to do this?…
-
5
votes3
answers221
viewsC++ challenge, helps with logic
I received a list of exercises from the programming teacher, this as a challenge. write a function with either return the expression value y = i - i^2 + i^3 -i^4 +i^5 - ... +- i^n I thought I’d make…
-
5
votes0
answers180
viewsQcamera Windows "failed to start"
I made an application with QT where I make the instance of a Camera with QT and display it in the window. So far so good, the problem is that when I want to display it in another window (Qdialog) I…
-
5
votes1
answer227
viewsProgram does not execute anything when it enters function
My program runs, but right after asking for the value prob() the .exe stop working. I thought it was some communication problem between functions on account of the matrix lattice[][4] as an…
-
5
votes1
answer1998
viewsDoubt how to display binary tree by width?
Good to use this method of flaunt need a line there all right, I tried this logic worked until the third level of the tree. bool marcador = true; void buscaLargura(No *raiz) { if(raiz != NULL) { if…
-
5
votes1
answer354
viewsQt calling method in another class
I’m calling a method another class after entering data. But it is returning an Sqlite error: QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries…
-
5
votes1
answer1131
viewsComplex numbers in C++
I’m new to C++ and would like to know how to use complex numbers: double real[2]={2,5}; double imaginario[2]{7,9}; cout << "Soma: " << real[0]+real[1] << "+" <<…
-
5
votes2
answers431
viewsCount elements in a range of values
Is there any more concise way to count all the elements of a vector (here in the example between 10 and 20) than the one presented? vector<int> v={1,2,3,45,24,10,20,-90,100,18,17,15,87}; int…
-
5
votes2
answers1246
viewsHow to add elements at the "x" position of an Std::vector
How to proceed to add an element at the position I specify in a std::vector? Not to delete what you already have, but to add in the middle. Here’s an example: Let’s assume that inside a std::vector…
-
5
votes1
answer459
viewsWhat is a shared_ptr?
If possible, with an example of code, as this is missing in the reference to really understand when and how to use the shared_ptr.
-
5
votes3
answers14329
viewsHow to use the C++ vector class?
Necessarily need the library #include<vector.h> To raise it vector <int> c; Question: How to store values in it and read them?
-
5
votes2
answers194
viewsWindows Universal Apps C++ vs C#
What’s the difference between C# and C++ to develop universal apps? I saw that in the templates of Visual Studio 2015 for C++ there is a group Cross Plataform with app templates for android and Ios.…
-
5
votes1
answer248
viewsWhat is the most appropriate way to store a reference in an object?
Suppose I want to create a library, where an object should receive another object added by the user and store it for later use. Ex: //header.h class Caixa{ private: Botao botoes[5]; public: void…
-
5
votes2
answers4801
viewsHow to use multiple languages in a single program?
I saw that Google Chrome is made in Python, C++ and Assembly and came to mind, like programming using multiple languages in a SINGLE program?
-
5
votes2
answers1808
viewsAssign a value to the pointer and multiply (directly)
How do I multiply the pointer so I assume a value to it? #include <stdlib.h> #include <stdio.h> int main (void) { int a,*b,*c,*d; printf ("\nInforme um valor: "); scanf ("%i",&a); b…
-
5
votes1
answer426
viewsWarning compared between floats how to proceed
In an exercise I did, you are asked to make a compound interest calculation with for for the values of 5%, 6%, 7%, 8%, 9%, and 10%. As I could not use a check per counter being the counter a type…
-
5
votes2
answers12195
viewsDifference between Std::Cout and Cout?
In C++ because some use std::cout and others use only cout is just what the programmer thinks best?
-
5
votes1
answer147
viewsIs it possible to "simulate" C++ Templates in C?
Taking a stack type data structure with array for example: typedef struct stack_s { int top; int item[STACK_MAX_SIZE]; } stack_t; Doubt appears when for some reason I want to use a stack with…
-
5
votes2
answers818
viewsPixel distribution algorithm
Well, lately I’ve been thinking about algorithms to create random maps/ images and I came up with a question that I’m going to post here for you to clarify. Suppose I have green and yellow pixels.…
-
5
votes1
answer821
viewsReduce a string in C language
How do I reduce the size of a string in C? In my program it is implemented as follows: char nomeString[] = "nomedoarquivo.txt"; I intend to cut the ". txt" of the end of the string.…
-
5
votes1
answer446
viewsClang has Character error Too large but Visual Studio builds normal
I’m having a hard time understanding why the Clang presents the error message Character Too large for enclosing Character literal type when trying to execute the code: char c = 'ç'; while Visual…
-
5
votes1
answer1182
viewsStatic functions in C
I noticed that some libraries use functions and static variables, for example static int sum(lua_State *state). This function belongs to a library that will be compiled into the language Moon. But…
-
5
votes2
answers393
viewsIf array is the same as pointer, why does one need to be copied to a variable and another need not?
In that reply Maniero said that if the member of the structure was a pointer it would not need to copy the string into it. But arrays are not pointers? Why is it different?…
-
5
votes1
answer637
viewsHow is a "struct" organized in memory?
How access to struct? Can I put members in the order I want? How does the compiler know which part of the memory to access? What would this look like? struct { char ch1; short s; char ch2; long long…
-
5
votes3
answers171
viewsIs it safe to create an object pointer in the stack indirectly?
My class has a method that returns a pointer to itself, and at some point I use the following : void classequalquer::metodo() { ClasseA * ponteiro = ClasseA().getThis(); //usa o ponteiro nesse…