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
-
0
votes0
answers859
viewsGame of life c++
Hello ! I am developing the game of life and I am not managing to get the rules applied correctly(I do not know if it is due to the function that prints or the function that checks the rules). For…
-
0
votes1
answer573
viewsProblem calling base constructor in inherited constructor in C++
I’m taking data structures in college at C++ and this language is really crazy. I am trying to call the parent constructor in the constructor of the heirs classes, but the following error appears:…
-
0
votes2
answers254
viewsProblem when compiling c++ Singleton
When I’m trying to compile a singleton I always get the following return message: g++ -g -Wall pkg-config --cflags stage -fPIC pkg-config --libs stage -c -Wall Connection.cpp cc Connection. o -o…
-
0
votes1
answer899
viewsNewton-Raphson algorithm
consider the Newton-Raphson algorithm for calculating the roots of the equation f(x)=0 with (0.5, 1 , 2 , 3.4556) for each initial x. f(X)=X 4-12X 3+47x 2-60X I made the same code as the algorithm,…
-
0
votes1
answer47
viewsHow do I place strings like 'char32_t' and 'char16_t' on the console in C++?
New C++17 added characters char32_t and char16_t, added also 'u16string' and 'u32string', but did not create any way to put them on the console screen. For example: int main() { std::u16string u16s{…
-
0
votes1
answer158
viewsFunction with template
Folks someone can help me. I have to do the following function below. Elaborate a function to return the highest value between two numbers, using template. The function should contain no more than…
c++asked 7 years, 2 months ago Carlos Ferreira 39 -
0
votes1
answer214
viewsReallocate My Structure Size in C?
typedef struct tempNo { int valor; int coluna; struct tempNo* prox; } NO; typedef NO* PONT; typedef struct { PONT* A; int linhas; …
-
0
votes4
answers123
viewsIs there a smaller way to resolve the question below? and know if it is correct
Create an algorithm that contains an integer vector. Then, your algorithm should generate two more vectors. The first vector must store the numbers of the initial vector in ascending order and the…
-
0
votes0
answers38
viewsHelp with string and libcurl c++
Good night. This is the first time I publish something here, I would like help with a program I’m doing to streamline some processes there at work, I’m not a programmer I’m just learning already…
c++asked 6 years, 2 months ago Guilherme Alves 1 -
0
votes0
answers37
viewsWM_KEYDOWN event not being called
I am developing a simple C++ program just for testing with a graphical interface but it is not calling the WM_KEYDOWN event, the program is based on dialog. The graphical interface was created…
-
0
votes2
answers118
viewsIncorrect value in subtraction of binary numbers using strings
I made this code and it basically gets two numbers in binaries (no separation of spaces between bits), and Performa (at least in the values I tested) the subtraction correctly. I tried to prevent…
-
0
votes1
answer186
viewscould not Convert | Error returning object
The purpose of the code below is to return the tokens of a particular expression, for example: 50+30*(30-10)+(10/2). Where the tokens would be: [number, 50], [sum, +], [number, 30], [mult,*] and so…
-
0
votes1
answer159
viewsHow to use template to specialize a function with char *?
I am doing C++ exercises and created a template for the function of returning the highest value. template<class Type> Type maximo (const Type a, const Type b) { if (a > b) { return a; }…
-
0
votes1
answer54
viewsInfinite loop in height growth analysis
Gustavo is 1.40 meters and grows G centimeters per year, while Juliano is 1.10 and grows J centimeters per year. My show is giving a loop infinite when I run. #include<stdio.h> int main() {…
-
0
votes1
answer43
viewswprintf problems with long int c++
Hello, I’m having trouble trying to "print" on "big" integers in c++. To be more specific, using the visual studio 2017 int main() { _setmode(_fileno(stdout), _O_U16TEXT); long rr =…
c++asked 6 years, 2 months ago umcaralegal9 35 -
0
votes1
answer68
viewsMy struct type is not recognized within my class
Guys, I’m implementing a stack with C++ pointers and have the following code for now: template <class T> struct Node { T item; Node *prox; }; class Pilha { private: int tamanho; Node *topo;…
-
0
votes0
answers37
viewsForce a class to have an attribute
I am doing a project and I need a parent class (heritage) to force its daughter classes to have a certain attribute. It is possible to do this?
-
0
votes1
answer162
viewsHow to compile c++ classes in Makefile?
I was making a program in c++(normally I was using an IDE to compile and everything), but this time I needed to do it without an IDE, anyway when I did Makefile to compile the program, it gave an…
-
0
votes1
answer68
viewsHow to use a template as a type in a map?
Is there any way to use template as type in a map in C++17? template<typename T> std::map<std::string, T/* tipo desconhecido, pode ser qualquer tipo */> map_exemplo;…
-
0
votes2
answers1368
viewsError: "cannot Convert 'int*' to 'int**"
I am trying to send the address of an array to a created function (which has as parameter a pointer that is also an array). The error is as follows: main.cpp: In function 'int main()':…
c++asked 7 years, 1 month ago MiguelTeixeira 60 -
0
votes2
answers1281
viewsHow to pass a vector class vector as a function parameter?
The contents of my vector are the data I wish to place in the matrix: int main() { vector<int> dados; int valores[4]; string val; ifstream arq ("matriz.txt"); if(arq.is_open()) { while(!…
-
0
votes1
answer201
viewsArduino (C++) send variable to PHP page
I have the following code in C++ on Arduino int variavelemc; variavelemc = 10; And I have the following code in PHP $variavelemphp = $_POST['variavelemc']; How do I pass the variavelemc to the…
-
0
votes2
answers139
viewsIs it possible to rewrite any code that uses pointers (C#) without using pointers in Node.js?
It is possible to rewrite any code in C/C# that uses pointers in a way that does the same thing without using them? My fear is more complex codes. The simple ones I believe are not difficult to…
-
0
votes0
answers37
viewsHow to control reading txt file
I have the following entry in a file .txt: var a; var b; var c; a = (10+2)/2; b = a*2; c = a*b; print a; print b; print c; Where the getToken() function will return me the current token, containing…
c++asked 7 years, 1 month ago lucasbento 856 -
0
votes1
answer238
viewsData does not persist on switch case
Write a program that registers the name, height, weight, Cpf and sex of some people. With the data registered, then locate a person through your CPF and print your IMC. When I choose the Query…
-
0
votes0
answers112
viewsMakefile in C++ - Geany
Good afternoon, I’m new to programming in C++ using Geany. And I’m having a hard time when it comes to creating an interface between a class and main, that is, creating a class, for example message.…
-
0
votes1
answer2659
viewsC++ program error: "[Error] expected Primary-Expression before 'F1'"
Hello, good evening everyone! I have a problem in my occurrence function of a number in the vector. The mistake: [Error] expected Primary-Expression before 'F1' Could someone help me solve this…
-
0
votes2
answers51
viewsOpencv in Codbloks c++
Someone can help me, I installed the opencv library, and I set it up in codeblocks, but still when I compile the project, dis…
c++asked 5 years, 12 months ago Deividy Henrique 11 -
0
votes1
answer32
viewsSegmentation float when starting the function for the second time
I created a program in c++ to manipulate matrices,and I divided the source code into 2 files, one with functions and the other with implementation, all functions work correctly, but when starting…
-
0
votes2
answers118
viewsmanipulation of some struct
I have a struct, how do I predefine data in this struct? example define life of struct 100? I’ve tried to dataplyer.vida = 100; struct dataplayer { int vida; int armadura; int arma; int level; };…
-
0
votes1
answer53
viewsis repeating only once
Code: #include <iomanip> #include <iostream> int main() { auto time = std::time(nullptr); std::string…
-
0
votes1
answer60
viewsOrdered List Logic Error (C++)
In the discipline of data structure, the teacher gave us a cpp code with an ordered list and asked us to implement the methods of binary search, sequential search and insertion, but I’m not able to…
c++asked 7 years ago Igor Alvim 5 -
0
votes0
answers169
viewsHow to import C++ project to VS?
I’m new in the C++ area, and I need to import a project into VS. I can only open the project folder, and edit file by file. C++ does not have a sln file. to open the entire folder context, I am very…
-
0
votes1
answer22
viewsImpossibility to search multiple strings in a file. txt
I’ve been trying to make a program to which you search for several strings in a . txt in the c++ language but can only search for one string My code: #include <iostream> #include…
c++asked 5 years, 9 months ago Noob Zando 1 -
0
votes2
answers871
viewsUse accents in the Cout command
Good afternoon. I know c++ uses another form of Asci, so there are no accents for example, so I come across problems like: int main() { cout << "é ó ê A ç"; } Returns: Ú ¾ Û A þ Is there any…
c++asked 5 years, 8 months ago Darius da costa 303 -
0
votes1
answer318
viewsCan you give include in previous folder in c++?
ex: it is possible to include main.cpp in the header. h?…
c++asked 5 years, 8 months ago nomeAleatorio 20 -
0
votes3
answers142
viewsSwitch locks command when entering a letter
I’m making a code that uses switch (because the user can’t give any input) where I need the user to determine if r0 will have the integer value of 1 or 2, any other number will cause the question to…
c++asked 5 years, 8 months ago Darius da costa 303 -
0
votes1
answer216
viewsHow to pass a vector as a parameter of a function in C++?
I am declaring this vector and I want to pass it as a function parameter, as I do? vector<string> matriz_ambiente; arquivo.open("teste.txt"); if (arquivo.is_open()){ while(getline(arquivo,…
c++asked 5 years, 8 months ago Lucas Araujo Azevedo 37 -
0
votes1
answer139
viewsHow to read all keys from a section of a . ini file? C++
Can anyone help me with this question? I wanted to read all the keys of a section in a file ". ini" and use them as string. Ex: [ITENS] pedido1 = 3552 pedido2 = 2208 pedido3 = 2066 pedido4 = 5787…
c++asked 5 years, 8 months ago Pedro A. Pinheiro 15 -
0
votes0
answers360
viewsCall a method of a class from a function within the class itself? C++
I created the "checkCase4" function in my Tree class and within it I make 2 class methods (rotate_left and rotate_right). Function: void checkCase4(Node *child, Node *grand) { if (child ==…
-
0
votes1
answer282
viewserror creating matrix with variables in c++
When I declare matrices in c++ within a class, defining "rows' and "columns" of that matrix by integer numbers directly with arguments, example [2][5] I can have the correct functioning. However…
-
0
votes1
answer72
viewsMatrix program error in C
I am starting now in C programming and I have a problem in my C program. The problem is that the printout matrix appears all zeroed. #include <stdio.h> #include <stdlib.h> int main (){…
-
0
votes1
answer149
views -
0
votes2
answers45
viewsException with variables
I’m kind of new with exceptions treatment, what I wanted to do was read a variable in c++ and in case it’s different from the kind I declared to fall in catch. int x; try { cin >> x; } catch…
-
0
votes2
answers1840
viewsOnline and shared programming
I wonder if someone can tell me (if there is) some online C++ programming platform so that two or more people can program in real time and share this program between them? I have a working group and…
c++asked 5 years, 7 months ago Tamires Berno 1 -
0
votes1
answer214
viewsWarning: libssl.so. 1.0.2, needed by /usr/lib/gcc/x86_64-linux-gnu/6/.. /.. /.. /x86_64-linux-gnu/libcurl.so, may Conflict with libssl.so. 1.1
I’m trying to copy a program that needs some libraries LIBS = -g -lmysqlcppconn -lpthread -lcurl -lboost_serialization -lreadline -lz -luWS -lssl The problem is that -lcurl and some programs need to…
-
0
votes1
answer58
viewsRead line by line file
Hello, I have a question about file reading. Well I’m starting to mess with files now, I would like to know how to read line by line a file and present these lines, already researched, but I only…
c++asked 5 years, 7 months ago Gustavo Daniel 11 -
0
votes0
answers570
viewsAlgorithm Shellsort C++
Good afternoon, you guys! Can anyone help me by explaining this code in c++: #include < stdlib.h> #include < stdio.h> #include < ctime> void shellSort(int numbers[], int…
-
0
votes1
answer1682
viewsCheck if a letter exists in the c++ string
I’m having problems in my function that checks the existence of a specific letter in a string (I don’t know much about pointers I only used because my other function wasn’t returning the string if…
-
0
votes1
answer173
viewswhile (Cin >> str) An equivalent code in Python
Need to read multiple items without a fixed amount, in c++ just do while (Cin >> str) what would be an equivalent python code? has an answer in English to this same question here in the stack,…