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
-
1
votes0
answers125
viewshow to traverse a pointer to set in c++?
Hi, I’m implementing Kruskal’s algorithm, but I can’t navigate one set< No*>* to test the FIND_SET method, which is a set< No*>* how should I proceed? (in the rest of the code I walked…
-
1
votes1
answer1216
viewsHow to read a keyboard number without using "enter" in C++
I want to create a menu in which the user chooses the option 1 to 5, I would like the user to type the number and the program to enter the option without pressing Enter. Follow an example #include…
-
1
votes2
answers162
viewsLimit time to Cin input
I did a little research on, but I just find solutions spliced in C, but I use C++. The doubt is basically what the title says, whether it is possible to limit the time until the user input the cin.…
c++asked 5 years, 8 months ago Darius da costa 303 -
1
votes3
answers10296
viewsHow to read a string with C++ space inside a function
I’m in the second semester of H.I., and I’m sorry if it’s a trivial mistake. I need to read a name and surname, for an agenda, I am using function and already tried Getline, Cin.get(variable, size),…
-
1
votes1
answer14
viewsremove include scores to point local folder
Well there is a way to remove double punctuation to point the file to a folder ? I’ve seen this in some projects, plus my include error if not using Example of how it is #include "../utils/bps.hpp"…
-
1
votes0
answers160
viewsIndefinite reference error - C++
Hello! I’m trying to compile my program into C++ (it calls a function written in the Perl language) and it’s returning a long list of errors "indefinite reference": testeperl2principal.o: na função…
-
1
votes1
answer1729
viewsHow do I inherit an abstract class in C++?
In Java we have the possibility to create abstract classes, but without the possibility of instantiating them, but we can create and instantiate a class that inherits the attributes and methods of…
-
1
votes2
answers71
viewsWhat is the meaning of the two points on that line?
The line is: foo() : myValue1(0xDEADBEEF), myValue2(0xBABABABA) {} I can’t understand what she does. Here the complete code: class foo{ public: foo() : myValue1(0xDEADBEEF), myValue2(0xBABABABA) {}…
c++asked 5 years, 7 months ago Gustavo B. 13 -
1
votes2
answers113
viewsError translating structure code from C++ to C#
I’m trying to read a string of a process, I found this structure on the Internet: struct name { wchar_t nome[32]; }; I did it that way: struct name { public char[] nome = new char[32]; } And is…
-
1
votes2
answers203
viewsSum of series 1+(2*3)+(4*5*6)+...+ n with iterative implementation?
My code: I have tried several times to solve this question, but I am not able to make the values not repeat and the sum variable multiplies the values within each index. If anyone can do it and…
c++asked 5 years, 7 months ago Dacio Azevedo 21 -
1
votes1
answer49
viewsCreate an algorithm that saves data in HD
I created a simple schedule to record a user’s contacts, but the teacher asked for the data to be saved in hard drive to preserve contacts even after shutting down the computer. I have to write all…
-
1
votes3
answers89
viewsHow to make the first letters that the user type uppercase?
An example, joão August How to make the first letter of the name and surname uppercase: João Augusto
-
1
votes1
answer269
viewserror: invalid Conversion from 'my_type*' to 'int' [-fpermissive]
The execution of my code returns this error written in the title. I don’t know what to do about it because, if you see the code, of course the type of the parameter is BlockGraph and not int. When I…
c++asked 6 years, 11 months ago João Oliveira 87 -
1
votes1
answer143
views"void *Reader(void *i)" What is the equivalent in C++?
I am studying Operating System and I have an exercise to do in C++ and I am with dual (the book brings only in Java), I have to implement a classic problem of reader and writer using semaphores and…
-
1
votes1
answer559
viewsQstring accents in Qt 5.9 results in bizarre characters
Hi, good afternoon, I have a question I can’t fix at all the code is as follows:.... QTextStream stream( &file ); stream.setCodec("ISO 8859-1"); stream << "<p align=center><font…
-
1
votes1
answer83
views -
1
votes0
answers397
viewsComparison of matrix and vector C/C++
I need to compare a user-inserted op vector with the top 10 columns of each row of a 12x12 array. for(k=0; k<10; k++){ for(i=0; i<12; i++){ for(j=0; j<10; j++){ if(op[k]==d[i][j]){ if(i==1)…
-
1
votes1
answer118
viewsvalidating only .com.br regex
Staff was modifying a regex to validate only specific domains ending with yahoo.com.br, terra.com.br, bol.com.br, Hotmail.com.br. Then gmail.com, or provider.net.br would be invalid. So I did the…
-
1
votes1
answer61
viewsNon-existent C++ class pointers, how does it work?
Sometimes I find myself in situations like this: #ifndef CRIARVENDA_H #define CRIARVENDA_H #include <QDialog> #include "cliente.h" namespace Ui { class CriarVenda; } class CriarVenda : public…
-
1
votes1
answer34
viewsWhat is the difference between span and string_view in c++20?
The two classes do basically the same, have a pointer to the first element of the array and the size of the array. I know that string_view is used for character arrays, but could not be used span…
-
1
votes0
answers84
viewsC libarchive error: Unsupported ZIP Compression
I am trying to read a file. zip using libarchive but am getting the following error on archive_read_data() Unsupported ZIP Compression method (deflation) Same error occurs with all other compression…
-
1
votes1
answer66
viewsWhy doesn’t this redacted code work the same as the original?
I’ve been studying C++ for a while and I want to train by rewriting functions already done by me in C# only in C++. I wrote a simple code that computes a IV of a Hash, very simple even, calling the…
-
1
votes1
answer288
viewsI have a question about inherited default builders
I am doubtful when trying to improve a POO exercise here.. (-) = without I have the PAI class with two constructors (one is default). In the FILHO class I have two more constructors (no-default). In…
-
1
votes2
answers380
viewsReturn of system(); c++
Someone could help me, for a while now I have this doubt, regarding how to pass to a variable the return of the function System(); This function executes a certain command in the console, and brings…
-
1
votes1
answer292
viewsError passing a method to another method. C++
I am a beginner in programming and decides to venture into a project with some friends, in it I need the program descending which the order of the routine based on a factor, I am passing to a…
c++asked 6 years, 11 months ago Guilherme Stabach Salustiano 11 -
1
votes2
answers1112
viewsregex for url validation
People made this regex to validate URL: const std::regex pattern( "(?:(ftp|http[s]?:[//])?)?([w]{3}[.])?" "(.*[.](com|php|net|org|br|dk|at|us|tv|info|uk|co.uk|biz|se)?)?"…
-
1
votes1
answer147
viewsHow to call class method within the thread?
How do I call a class method inside a thread? I have a very simple thread and a class method. How do I call it inside the thread. As it is in the code below the compiler gives error #include…
-
1
votes1
answer473
viewsHow to concatenate the name of a variable into C++?
Is it possible to concatenate the name of a variable into C++? Something like this: using namespace std; int main() { int casa = 10; string a = "ca"; string b = "sa"; cout << a+b <<…
-
1
votes1
answer41
viewsProgram in c++ hangs when I use a function to pick up a file name
I’m making a small IDE in c++ and I’m having trouble getting a file name. ex: the full file path is "Keywords//cplusplus.txt" but the file name is "cplusplus.txt". So I wrote a function to get his…
-
1
votes1
answer168
viewsString Split in C++
Folks I’m looking for a split on the following String in C++ [ { "Nome":"Gabriel", "idade": 23 } ] I’m doing it this way... I receive this json through a query get and storing in a string to power…
-
1
votes0
answers29
viewsCreating a Splash Screen in dll
Well I need to show my user what is being verified, for this I need to make use of a splash screen, I was wondering if there is any way I use WPF to write the code inside my dll? I need to do in dll…
-
1
votes1
answer54
viewsStrange error in class c++
I have the following code: #include <iostream> using namespace std; class guns{ public: string name; int ammo; void reload(){ ammo = pente; } void shoot(){ ammo -= 1; } private: int pente =…
-
1
votes1
answer379
viewsWhat are the differences and advantages between "typedef struct" and "struct"?
I saw that the structure statement is not a standard among many programmers, while some use the typedef struct, others use only struct. Which is best to use? Has some difference in performance?…
-
1
votes2
answers1571
viewsReading Binary File in C++
Good morning. I’m trying to make a read of structs that I inserted in a binary file, but is giving error at the time of reading. Follow the code of the reading function: void lerRegistros(char*…
-
1
votes2
answers41
viewsWhen I try to display the values of a vector some more zeroes appear
I want to display some values of my vector, but before displaying the values are appearing some zeros. #include <iostream> #include <vector> using namespace std; int main(){ int…
-
1
votes1
answer151
viewsC++ string protection using Mysql Connector
I made a little program to check my database, and wanted to see if the strings were protected (from the password user and the database) and in the case are not. I decompiled the program using IDA…
-
1
votes2
answers322
viewsWhat does a semicolon mean after an "if"?
I was analyzing a code and came across a semicolon after a if, which means using the semicolon after a if? code: int base_calc(int cb) { if( cb < 30 ) { ; } else if( cb < 20 ) { cb = 30 - 1; }…
-
1
votes1
answer45
viewsAssignment operator overload returns a C++ reference
I’m having doubts about the overload of C++ language operators. I could not understand why the overload of the atibuição operator returns a reference, if I give a return *this (to my understanding)…
-
1
votes0
answers71
viewssee how many times a number changes position in c++ using Bubblesort
Could someone give an example of how I would do that? Type, a size 5 vector, with the following numbers: 33.64.21.85 and 15. I wonder how many times he compares the numbers and performs the…
-
1
votes3
answers124
viewsHow can a pointer point to a function?
A pointer points to a memory address, so how a pointer is able to point to a function? If the answer is "functions also have addresses" then please give more details. And if it is possible to…
-
1
votes1
answer821
viewsinvalid Digit "9" in octal Constant Arduino
I have a problem with my temperature measurement function. #include "max6675.h" int ktcSO = 8; int ktcCS = 9; int ktcCLK = 10; MAX6675 ktc(ktcCLK, ktcCS, ktcSO); void setup() { Serial.begin(9600);…
-
1
votes1
answer110
viewsStore multiple boolean states in only one bool variable
The guy bool so much at C as in C++ consumes at least 1 byte of memory to be stored, I saw that this is because it needs to be addressed or something. So, it would be like this 1 byte to store more…
-
1
votes1
answer100
viewsC++ Reach Problem
I’m a beginner in C++ programming and came across a problem when trying to execute my code on Atom, using the gpp-Compiler package and Mingw: 'Function' was not declared in this Scope (l.8). I…
-
1
votes1
answer90
viewsOperator overload = in c++
I’m having a problem implementing operator overload = in a heap class. Heap& Heap::operator=(const Heap& outro){ printf("chamei atribuição\n"); this->escreve(); Heap *h = new Heap(outro);…
-
1
votes2
answers64
viewsRepeat odd numbers with do while
Hi, I need to make a code inside a switch, which reproduces all odd numbers from 0 to 200, with the repeating structure do while. I googled and only found with for. I tried to put the "odd 200%2!=…
c++asked 4 years, 7 months ago Gabriel Diniz 13 -
1
votes1
answer100
viewsApplication Bubble Sort with random vector
Guys someone can help me with this code, I have to use the Bubble Sort to sort a random vector of n positions, but I can’t solve the error. #include <bits/stdc++.h> using namespace std; const…
c++asked 6 years, 9 months ago Carlos Ferreira 39 -
1
votes1
answer46
viewsHandling of c++ files
I’m having trouble manipulating a file. Always error on that part, specifically on that line "while(getline(alunosE, line)){", and I don’t know why. ifstream alunosL; string linha;…
-
1
votes3
answers737
viewsTemperature converter
When I type the temperature in Fahrenheint the program returns 0 as a result, where is the error? #include <cstdlib> #include <iostream> #include <conio.h> #include…
-
1
votes2
answers48
views -
1
votes1
answer311
viewsdouble free or corruption (out) - Using C++ matrices
I’m writing a class that deals with C++ matrices. However when creating a method to calculate the determinant of a matrix I am bumping into the following error: double free or corruption (out)…