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
votes2
answers2629
viewsCode::Blocks - error: Stray ' 240'
I am facing a simple problem, I believe. Saved my file in .cpp in Code::Blocks and then I try to compile it. However, when I compile, some errors appear (mingw compiler usage): Compiler Settings:…
-
0
votes1
answer49
viewsDeck(C++): Abort Trap 6
I’m trying to call a function I’ve done, but always this error appears: libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: deque EXECUTAR FINISHED; Abort trap: 6; tempo…
-
0
votes2
answers257
viewsHow could I enter the structs in a list?
#include "stdafx.h" #include <iostream> using namespace std; struct FICHA_INSCRICAO { char nome[50]; char cpf[10]; char logradouro[100]; char…
-
0
votes1
answer112
viewsHow to debug a C/C++ application remotely using ECLIPSE, different operating systems?
I am developing a C++ application that runs a Nanopi M3 board with Linux specially compiled for my purpose, and there have been certain errors and unexpected behaviors, I would like to be able to…
-
0
votes1
answer352
viewsCould you add a parameter in: system("color", var) in the C language?
I’m creating a simple program to change the color of the system. Only, I want to give the option for the user to write the color he wants. Ex: Has the table 1: Blue 2: Green F: Red C: Yellow F being…
-
0
votes1
answer95
viewsLibraries in Cmake as a project submodule
I am developing a C++ project where I make use of some libraries that I produced earlier, the problem that I don’t know how to import them in this new project of mine without putting the full path…
-
0
votes2
answers5055
viewsLargest/Minor/Sum in C++ using for
I want to make a program that reads 5 numbers and tells me the largest number, the smallest number and the sum of the numbers, in C++ using the loop for. I’ve tried and done so: #include…
-
0
votes1
answer129
viewsError when using inline methods in C++ classes: Undefined Reference to
I’m optimizing part of my code where some methods that are called loop very often I’m passing them to inline, but while doing so I’m getting the following error messages: And I’m getting the…
-
0
votes0
answers54
viewssetlocale does not work on RAD Studio C++ Builder apllication console
#pragma hdrstop #pragma argsused #include <stdio.h> #include <locale.h> #ifdef _WIN32 #include <tchar.h> #else typedef char _TCHAR; #define _tmain main #endif int _tmain(int argc,…
c++asked 7 years, 7 months ago Eduardo Silva 1 -
0
votes1
answer196
viewsProblems opening c++ software on another PC
I am developing a software in c++ using Visual Studio 2015, and I am using two external libraries, OPENCV and Flycapture2. I developed the software and it runs normally on my computer, but at the…
-
0
votes2
answers5430
viewsa Function-Definition is not allowed here before '{' what does this error mean?
I am trying to compile my code, but the compilation returns the following error: a Function-Definition is not allowed here before '{' token| I am beginner and I have looked several times the code to…
-
0
votes2
answers714
viewsSeparating substrings and storing in C++ variables
So I created a function that reads a text file and stores, line by line, in a string array by removing commas. The file entry is : add $t2, $t3, $t4 sub $t5, $t6, $t7 addi $t6, $t7, 4 Applying the…
-
0
votes1
answer62
viewsCan c++ templates only be used once?
I have this code in c++ and am getting an error: #include<iostream> using namespace std; template <class T> void setVector(T* v, int sizeOfV){ for(int…
c++asked 7 years, 7 months ago Sergio Souza Novak 513 -
0
votes3
answers4203
viewsGenerating random numbers C++
Hi, I’m writing a simulation in C++ and I have to generate some random numbers. To do this, initialize ( srand(time(NULL)) once and I have a method as follows: void…
c++asked 8 years, 1 month ago Antonio Gomes 15 -
0
votes1
answer87
viewsDefine an overloaded + Operator C++
I could not resolve the following question: Fill in the Blanks to define an overloaded +Operator for the class "Test". Test Test::______(Test obj){ ___newObj; newObj.mem= mem__obj.mem; return…
-
0
votes0
answers451
viewsSaving txt files with c++
I am trying to create a program that saves data stored with hash in 4 different txt files, depending on the index of the hash it chooses the file to save. example: hash índice 0 = txt_0.txt hash…
-
0
votes2
answers648
viewsHow to add the values in a loop?
I want to add and show the total value of the consultation. In the case of 3 patients the sum would be 1350. But something is going wrong. case 2 : printf ("Particular:\n"); printf("O valor da…
-
0
votes1
answer79
viewsHow to use an unmanaged DLL in the Microsoft Bot Framework?
I want to make a bot for facebook using Microsoft’s Bot Framework (C#) and also use a tool called Chatscript, which is written in C++. I turned chatscript into a DLL and called it in a console…
-
0
votes0
answers209
viewsCall c# function from within a c++ dll
Situation: I have a 3-layer project: One for data, one for C# and one for C++. The c++ layer is made using support for clr (Common Language Runtime Support (/clr)). But I use it as wrapper between…
-
0
votes1
answer114
viewsPush Back with copy builder
I don’t understand why when I create a copy constructor and push back on a vector, it calls the constructor more than once! If I do only 1 push back, it will show 1 time the copy builder. if I do 2…
-
0
votes2
answers879
viewsPass matrix to C functions
Good evening, next I have a problem passing a matrix to a C function. I have the following code void funcao(int mat[][num]); int main() { scanf(%d,&num); } It is basically the following, I…
-
0
votes1
answer367
viewsGrab file names and put in char array
As I take the filenames of a directory and place them in a multidimensional char array? #include <stdio.h> #include <dirent.h> int main() { char arrayNomes[10][50]; char dirn[50]; DIR…
-
0
votes0
answers61
viewsFIFO - Reestablish communication in C++
I have a main program written in C++. It fires children programs using vfork() and execl(). The communication between them works perfectly using FIFO (the father writes and the son reads). In the…
-
0
votes3
answers1589
viewsHow to read file line . txt from index 0
I have the following excerpt of code that reads line by line from a text file, ending until the beginning of string. How should I change it, so that such action occurs in reverse? while (getline…
-
0
votes1
answer574
viewsHow to check if the value of a key exists on a map in c++
I am doing a graph TAD and I use a map structure to map the ID of a vertex to its index in the adjacency matrix and to do this I need to first check if given the vertex id it is already added to the…
-
0
votes2
answers2922
viewsC/C++ library for manipulating images
I would like to know which library to use, which is easy to install for both Windows and Linux, to manipulate images ( png, jpg, etc) in C/C++ ? I would like to open and save it in an array to work…
-
0
votes1
answer109
viewsHelp with C++ bit scrolling
Well, in a programming exercise I was given the following program, and I asked what is your output using namespace std; union U1 { union U2{ unsigned a: 3; unsigned b: 4; unsigned c: 1; }u2; int d;…
c++asked 7 years, 12 months ago Sávio Bezerra 1 -
0
votes1
answer241
viewsHow to catch the line below (next line) in C?
Good morning people, I have a file that contains several lines, among them the following: REMARK Evaluations: CoarseFF Proper-dihedrals Coarse Atomic Repulsion Coarse Compaktr Hbond_Strands…
-
0
votes1
answer721
viewsProject error in Code::Blocks
I have installed the g++ and Code::Blocks (Linux-Ubuntu) and created a project and used the test file code (main.cpp) of Code::Blocks, when I give run a written tab appears It seems that this…
-
0
votes0
answers783
viewserror: no match for 'Operator<<' (operand types are 'Std::ostream {aka Std::basic_ostream<char>}' and 'const Std::runtime_error')
Code of the program main #include <iostream> #include "CntrIU.h" #include "CntrNeg.h" #include "interfaces.h" #include "stubs.h" #include <cstdlib> using namespace std; int main() {…
-
0
votes2
answers1171
viewsDLL import in C#
I joined a recent project that uses a Nearby printer to print tax coupons. The last one who worked on the project used a DLL (if I’m not mistaken in C++) that managed the printer. In the project,…
-
0
votes1
answer191
viewsAvoid memory leakage in return function
There is an exercise in the C++ book that asks you to create a function that returns an object avoiding memory leakage. I did so but I’m not sure if it really works: class Point1{ public : int x;…
-
0
votes1
answer30
viewsHow to remove the class name from the executable without losing dynamic_cast?
My goal is to just remove the class name from the executable, but still continue with the ability to use dynamic_cast. The problem is that if the RTTI is removed, and thus the class names, there is…
-
0
votes1
answer99
viewsC++ Doubt-Basic Solution Northwest Corner
I’m kind of forgotten about programming and I have a math algorithm to do, it’s the transportation problem, I’m in the northwest corner phase. My doubt is in a build error. Code:…
c++asked 7 years, 10 months ago Sergio Souza Novak 513 -
0
votes1
answer867
viewsUse of arrow keys to generate movement in play
I wanted to know how the developer of the game Snake in C++ merged with C made the snake move from the arrow keys. I think the part where it moves is when it compares tecla=='K' tecla=='H' and so…
-
0
votes2
answers125
viewsI cannot use char '&' Qt Creator
I am trying to return a Qstring, which will be used as a URL and I need to use '&' as a separator in the URL. However, when the character is placed in Qstring, it breaks the URL and what should…
-
0
votes1
answer36
viewsHow to send the main program programming directive to some library?
I have a library that generates a result of two allowed. This is given by the definition, within the library itself, of the directives #define __SE8R01__ or #define __RF24L01P__. The case is that…
-
0
votes1
answer74
viewsIs this valid (x = (*mat)+;)?
(x = (*mat)++;) If it is valid, explain to me why and how it will work.
-
0
votes1
answer90
viewsStacks with sequential allocation
I’m having problems implementing the code of a stack using vectors: typedef struct pilha pilha; struct pilha { int *v; int topo; int tam_max; }; void Inicializar_Pilha (pilha pi, int tam_max) {…
-
0
votes1
answer1360
viewsCall any function of another class of the same type
I need to pass as a parameter to a member function another member function (but of another class). I can do this for same class functions, but from another #include <iostream> using namespace…
-
0
votes1
answer150
viewssprintf does not give the expected result
I have variables of the type Unsigned Long Int and would like to save its value in a string, to perform calculation of checksum and send via serial communication. void Payload(int long unsigned…
-
0
votes1
answer568
viewsI am unable to pass one vector per parameter in C
I am trying to pass a vector per parameter to a function in C, but I am going through difficulties. #include <stdio.h> #include <stdlib.h> #include <math.h> void calculafx( x2,…
-
0
votes2
answers86
viewsChange type of return
How do I change the return type of a mother class function in the daughter class? For example: class Mother { public: void Get() {} }; template <typename Type> class Child : public Mother {…
-
0
votes2
answers85
viewserror: use of Deleted Function Fight::Fight()'
Good afternoon, I am experiencing several problems when compiling the code below in the code::Blocks with g++ and I would like to get help, thanks in advance. Content of main.cpp: #include…
-
0
votes1
answer284
viewsImport Python DLL into C++
How do I compile a Python class in DLL in order to import it into C++, using Python features that are not available in C++? I want to be able to import it without having Python installed on the…
-
0
votes1
answer455
viewsOperator overload ==
bool Stock::operator== (const Stock& stk){ if ( this->get_resource() == (stk.get_resource()) ) return true; else return false; } I created this method to overload the operations of a class,…
-
0
votes0
answers117
viewsI am using c++ with the openGL library
I’m using c++ with the openGL library, I’m having a little trouble creating a method. I need to create some buildings randomly, but to not create one inside the other I need to compare the 4 points…
-
0
votes0
answers132
viewsHow to edit the Full Path property of the file in Visual Studio
I added an existing file to my project. With this, it fixes the Full Path of my file, and I can no longer change. What I need to do is edit this value by using variables such as $(SolutionDir), so…
-
0
votes0
answers104
viewsMPI running together with Gurobi
I’m trying to make a simple code in c++ which aims to run 1 million PL (linear programming) with the gurobi optimizer using MPI parallel processing. The problem is that when using MPI and Gurobi…
-
0
votes2
answers1476
viewsPrint components of an array in reverse order
I wrote a code to print the components of a array in reverse order. However, it only returns 5 or 6 numbers (at most), even if I have put more numbers in it. #include <iostream> using…