Questions tagged as 'c++'

1
answer

C ++ - Sorting particular points of a rectangle in a vector?

I have a project in c ++ where I should map regions of an image using the mouse click. The issue is that I need to get the mapping points in a specific storage order, as in the image below: My problem starts at the moment of storing thi...
asked by 19.08.2016 / 06:27
1
answer

Using template, why use const modifier in this variable (C ++)?

#include <iostream> using std::cout; using std::endl; template <unsigned int i> struct Fibo{ static const unsigned result = Fibo<i-1>::result + Fibo<i-2>::result; }; template <> struct Fibo<0>{ stati...
asked by 27.12.2018 / 20:51
1
answer

Creating processes with fork

I'm creating a sequence of processes through the command fork , but when I was listing the processes generated by the code, I came across that there was a larger amount than I had created. Why this?    By 10 forks 1024 proces...
asked by 28.01.2017 / 05:22
1
answer

Free memory in C ++

Am I required to free up memory for every variable I am no longer using? If yes, how?     
asked by 02.09.2015 / 15:05
1
answer

Sort in C ++ does not show the correct input value

I made a code to read 3 values, and with sort() it sorts the values in ascending order and just below shows the input values. For example: -14 21 7 it orders right but output shows -14 7 21 // 21 21 7 being that it was to be -14 7 21....
asked by 19.08.2018 / 04:05
2
answers

What is the difference between the expressions "int a" and "const int & a" as function arguments in C ++?

Let's say I have two functions: int soma_a(int a, int b){ return a + b; } and int soma_b(const int& a, const int& b){ return a + b; } What would be the difference between soma_a and soma_b     
asked by 07.08.2018 / 21:55
1
answer

Passing by reference printing garbage in the vector

Personal I made a simple code but I have a problem. I did an "increase" function to increase the size of a vector; The function receives the vector and passes the values of that vector to an auxiliary vector. So I can delete the vector, allocate...
asked by 05.06.2017 / 06:14
1
answer

Why does the output give 16?

#include <iostream> int main() { int x, y = 3; x = (++y) + (++y) + (++y); std::cout << "y = " << y << std::endl; setlocale(LC_ALL, ""); std::cout << "O valor de x é " << x << std::end...
asked by 31.01.2018 / 19:29
1
answer

What are the most common C ++ compilers in Linux? [closed]

What are the most common free compilers on Linux to compile C ++ 14? "Most common" in the sense of most used and available in various distributions. I'm using CENTOS and I need to compile codes that use the new features of C ++ 14.     
asked by 09.03.2018 / 21:17
1
answer

Send two triangles to a vertex shader. OpenGL, C ++, GLSL

I'm learning in college graphics processing with OpenGL in C ++. We are using the GLFW and GLEW libraries. My program consists of creating two triangles in different parts of the window. I created an array with the coordinates of the triangle, a...
asked by 06.05.2018 / 04:01