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
-
3
votes1
answer628
viewsCode for earlier than expected
Follow the code with my suspicions: Header: class Name_pairs { public: void read_names(); void read_ages(); void print() const; void sort(); // Ordenar os nomes com as idades private:…
-
3
votes1
answer193
viewsDifference between pointer vector for a class and vector for a class?
When is pointer to class will we have to allocate memory space? What is the difference between the following two statements and when they should be used ? Vector <class*> nameOfVector; Vector…
-
3
votes1
answer701
viewsWhat are C++ pointers really used for?
Where pointers are actually used? I’ve searched so many places and the example is always theoretical. I would like to know a real situation, an example within a real project in which pointers are…
-
3
votes3
answers603
viewsHow to check any received type (upper or lower case)?
How can I make upper and lower case be ignored to compare with default word? Ex: stack(default word to compare) Words that could be received: "Stack" "Stack"
c++asked 7 years, 10 months ago jorge saraiva 478 -
3
votes1
answer61
viewsIs it possible to initialize a structure partially indicating the members?
In several languages it is possible to initialize a struct, or class, indicating which members want to put some value: var obj = new Tipo { b = 1, e = "x" }; In C we can initialize members in order:…
-
3
votes1
answer289
viewsWhat is the difference between using #include "stack. h" or using the class statement ?
Having these two classes in two files .h distinguished. a. h class um { //(...) }; two. h #include "um.h" //opcao 1 class um; //opcao 2 class dois{ public: void f1(um * p); }; What is the difference…
-
3
votes1
answer1285
viewsOpen files by passing variable as file name
I have the following situation, a file "tables.txt" where I have around 2000 lines with filename to which I want to pass row by row taking the name of the files and check which ones exist and which…
-
3
votes2
answers74
viewsWhere is the function that a decayed lambda to pointer points to stored? How is it released?
I learned recently that I can do this: auto a = +[]{return true;}; a = +[]{return false;}; And I understood that a lambda that captures nothing can decay to a pointer for function, as confirmed by…
-
3
votes1
answer185
viewsHow to track mouse coordinates on a Qlabel?
Hello, I’m with a screen project using Qt Creator and I’m stuck with the following problem: I want to track the mouse coordinates by moving the cursor over a Qlabel. I saw in some other topics some…
-
3
votes1
answer538
viewsQt5widgets.dll error when it is installed to another computer
I’m trying to export an application built in Qt 5.7.0 (compiled to 32 bits, although development takes place in a Windows 10 environment, 64 bits) to another computer (this one with Windows 8.1, 32…
-
3
votes1
answer322
viewsHow big is an "Enum" in C?
In general the enum keeps a whole, I can consider that this is the size of it?
-
3
votes1
answer246
viewsQT - Identify coordinates of an image in a different size Qlabel?
Hello, I recently had a question about how to track coordinates of a Qlabel using the mouse cursor. It worked fine for what I was thinking of doing. What I intend to do is the following, I have an…
-
3
votes1
answer687
viewsHow does the frame-Pointer work?
In the official GCC documentation there is a option that allows you to remove the frame-Pointer when it is not necessary. What the frame-Pointer ago? How removing this pointer can improve…
-
3
votes2
answers125
viewsShould I use int_least8_t or int_fast8_t?
I am studying the limits of types that c++ 11 brought and I noticed that there are officially several types of integers. In addition to the Joint Declaration int now I can declare: int8_t…
-
3
votes2
answers425
viewsUse delete on allocated objects without new?
Hello, from always until today in my c++ projects with Qt, I have always used delete objects only when I dynamically allocate them with the operator new, But in my last project that was relatively…
-
3
votes2
answers377
viewsHow to generate a . of the implementation of a class . cpp without the main function in g++?
I would like to compile the implementation of a class in order to only generate an object code from it. This is the implementation of the class: #include <iostream> #include "gradebook.h"…
-
3
votes2
answers1554
viewsHow to clear the array name so it doesn’t end up with the rest of the previous strings
#include <iostream> #include <string.h> using namespace std; int main() { int condicao; cin >> condicao; //Determina o tamanho do vetor…
-
3
votes2
answers1115
viewsTreatment of exceptions in C++
I have a question regarding the treatment of exceptions in C++, the class Fracao below is purposely incomplete does not even possess setters or getters and several things have been "set aside", has…
-
3
votes1
answer164
viewsDoubt about simple chaining in c
I wanted to know why removal processes in threads have two pointers set to next like this given example void remove (celula *p) { celula *lixo; lixo = p->prox; p->prox = lixo->prox; free…
-
3
votes1
answer2985
viewsStd::Sort with comparison function
Studying a little about the STL I came across the function std::sort which may receive a comparison function. template< class RandomIt, class Compare > void sort( RandomIt first, RandomIt…
-
3
votes1
answer150
viewsIs it possible to determine the hardware address of the router?
I’m trying to get the hardware address of another device (actually the equipment connected directly, like a modem/router) on the same network, I was able to do this: foreach(QNetworkInterface…
-
3
votes1
answer102
viewsProblem with handling txt files in C++
I am developing a C++ program that should read the keyboard data store them with hash, after performing the reading it must have in its main menu the save option. I can read the save files using the…
-
3
votes1
answer87
viewsChange the property of a QML object by C++
I’m trying to change a property of an object (Rectangle) that was instantiated in the QML, but I am not able to perform it because the method findChild returns null. I am following the following…
-
3
votes1
answer84
viewsDownload great with Qnetworkreply::readall freeze for a few seconds
When using QNetworkreply::readAll to save the data to a QFile, the moment the download arrives at the end occurs a quick freezing of 2 to 4 seconds and also varies according to the network or site I…
-
3
votes1
answer875
viewsCreating a Makefile
I’m needing to write a Makefile, I was able to configure something by searching, but I tried to improve more for what I need, and I’m not getting it. What I’m trying to do: 1 - Check all files . c…
-
3
votes1
answer131
viewsVariable type of return
I want to do functions with variant input type, like this: int count(vector<auto> base, auto val) { int sum= 0; for (auto it : base) { if (it == val) { sum++; } } return sum; } or this: string…
-
3
votes1
answer180
viewsHow to get a string from an hbitmap
I have a function that captures the monitor image and creates a bitmap file with the result, but I would like you to return a string with the content that the file would have, instead of writing it…
-
3
votes2
answers714
views -
3
votes1
answer79
viewsCode works sometimes yes and sometimes no
This is my code: #include <iostream> #include <cstdlib> #include <ctime> using namespace std; void exchange (int *arr, int i, int j) { if (i == j) return; int aux = arr[j]; arr[j]…
-
3
votes3
answers610
viewsRegular expression for email in C++
I have the following regular expression in a C++ format validation function using regex, but it is validating non-standard formats that I want. b[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}b\\.[A-Z]{2,4}b…
-
3
votes2
answers590
viewsIs it possible to develop a C++ application in Visual Studio to run on Linux?
I have to develop an application for Linux in C++ and wanted to know if it is a good use Visual Studio 2017 in Windows for such task? I wanted to know the pros and cons, because I saw that the VS…
-
3
votes1
answer112
viewsAbout __forceinline and __inline
What is the difference between using __forceinline or __inline? And you can use __forceinline or __inline large-scale? Example: __forceinline void funcao1(void) { cout << "Funcao 1" <<…
-
3
votes1
answer2472
viewsUndefined error Reference to Std
#include <iostream> using namespace std; int main() { int nombre, carre ; cout << "Introduza un numero : " ; cin >> nombre ; carre = nombre * nombre ; cout << "A raiz…
-
3
votes2
answers307
viewsC Cast vs C++ Cast
What’s the difference between using the C cast: float t = 5.0f; int v = (int)t; For the cast of C++: float t = 5.0f; int v = static_cast<int>(t);…
-
3
votes1
answer277
viewsKnowing which class of daughter the parent class points to
I came from Java and I have a question about polymorphism in C++. Given these classes: class Empresa{ vector<Pessoa> pessoas; int empregados; addPessoa(Pessoa* p) } class Pessoa { ... }; class…
-
3
votes1
answer193
viewsHow to measure times in multi-threaded C programs
I’m doing a multi-thread work in c, and I need to calculate the time of a certain part of the program, does anyone have any idea how I can do this?
-
3
votes1
answer637
viewsRandom value in C++
I was practicing a little C++, I created that simple data game exercise, so I came across a problem, how can I generate random values in C and C++? Taking a look at the site (c plus) I found an…
-
3
votes1
answer169
viewsHow to rotate a set of vertices around a pivot
I have a set of vertices that I need to rotate at an angle Θ around a pivot, but when I apply the transformation the vertices distort. What’s wrong? I got the answer formula for a similar question…
-
3
votes2
answers59
viewsWhat is the usage limit of . push_back()?
I use a lot .push_back(element) when I’m working with vector, but I don’t know what’s the most elements I can add to a vector before it overflows and performs the reallocation of a new space in…
-
3
votes1
answer540
viewsLinear recursive search c++
I wanted to do a recursive linear search using vector and iterators, here’s the code: long int busca_sr(std::vector<long int> &amostra, const long int &key){ auto first =…
c++asked 7 years, 8 months ago Jhonattan Cabral 51 -
3
votes1
answer244
viewsDo not compile, error: use of Deleted Function
I have a simple project on codeblocks (windows), I’m using the library SFML, when trying to call a method I created where I pass the window and any object, in the act of compiling I get the…
-
3
votes1
answer306
viewsPHP x C++ web performance and security
Today I work in a company that manages some sites with too much traffic, which is generating some problems of server overload and etc. These sites are mostly news portals and are running Wordpress,…
-
3
votes1
answer949
viewsHow to take line break in the "Cin" of the <iostream> library?
How can I take the line break when reading some variable with cin? #include <iostream> using namespace std; int main() { int dia, mes, ano; cout<< "Data: "; cin>>…
-
3
votes1
answer1155
viewsImport python C++ modules
I’m trying to import into one script python a module C++: import hector_path_follower The archive c++ defines a namespace for the class: namespace pose_follower { class HectorPathFollower { ... } }…
-
3
votes2
answers1038
viewsHow to omit parameters in the actual parameter passage?
I have a C++ function called minhaFuncao() thus declared: minhaFuncao(int x, int y, float a); and thus implemented: minhaFuncao(int x, int y, float a=0){ ... } What I’m trying to say is, when you…
-
3
votes1
answer5346
viewsDifference between "<iostream>" or "<stdlib. h> <stdio. h>" in #include
I am learning to code in c++, and I would like to know the difference in programming with the library #include <iostream> or libraries #include <stdlib.h> #include <stdio.h> One I…
c++asked 6 years, 7 months ago Prometheus 97 -
3
votes1
answer403
viewsHow to get the same strcpy() result with strcpy_s()?
I downloaded a C++ code from the internet and when I open the solution, the following error: Error C4996 'strcpy': This Function or variable may be unsafe. Consider using strcpy_s Instead. To…
-
3
votes1
answer100
views -
3
votes2
answers1731
viewsInsert elements into array of C++ lists
I’m having trouble inserting elements into a list array. The program prints the quantity_de_vertices variable and then a runtime error occurs. #include <iostream> #include <list>…
-
3
votes1
answer58
viewsUse Opencv in Ubuntu c++
I am using Ubuntu with Opencv to develop a computer vision method, previously used in windows Opencv and put the following configuration in qtCreator to recognize Openccv. INCLUDEPATH +=…