Questions tagged as 'c++'

2
answers

Make a reference variable point to another variable

I have the following question, for example: int a = 5; int b = 10; int & r = a; How do I make the reference variable r point to b and not more to a ? Is it possible to do this?     
asked by 08.09.2015 / 00:22
1
answer

Should we neglect the return of functions in C that already receive the desired value by the parameter by reference?

Looking at the documentation from scanf() I saw it return a value, but I see the codes using her without making use of this return. Is this right?     
asked by 13.03.2017 / 14:35
1
answer

You are not generating the 1000 random numbers required

I'm developing a program in C that randomly generates a thousand numbers and that in the end appears the largest and smallest of them. For this, I'm using rand() . But I have a problem. When I run only less than 300 numbers are generate...
asked by 05.11.2014 / 22:06
1
answer

Complex numbers in C ++

I'm new to C ++ and would like to know how to use complex numbers without being as follows: double real[2]={2,5}; double imaginario[2]{7,9}; cout << "Soma: " << real[0]+real[1] << "+" << imaginario[0]+imaginario[1] &l...
asked by 10.12.2015 / 23:53
1
answer

Assign an expression to a variable

In c ++ is it possible to execute expressions within a variable? Ex (in Moon): n = math.random(9, 10) a = n .. (#tostring(n) > 9 and "-" or "--") print(a) If n were equal to 9 would return: 9-- If not, I would return 10- In c +...
asked by 21.12.2014 / 08:14
1
answer

How to reduce the spacing between characters printed with \ t in C ++?

I wanted to put the columns closer so that they do not happen as in figure 2. int i,j,elemento; for(i=0; i<elemento; i++){ for(j=-elemento; j<=elemento; j++){ if(i >= abs(j)) { cout<<"\t"<<abs(j)+1...
asked by 31.08.2018 / 20:11
2
answers

What is the problem of returning a local variable?

What can happen if I return a local variable? I read on the internet that it is not a good idea to return a local variable. Maybe because the variable when exiting the function is deleted? Example: std::string StrLower(std::string str) {...
asked by 22.04.2018 / 14:56
2
answers

What is the suffix _t and when to use it?

I see in many codes some variables with the suffix _t . There are a lot of examples in the default C library as size_t , int32_t , mbstate_t . How useful, and when to use this suffix?     
asked by 29.09.2016 / 15:48
1
answer

Build GUI for Windows without using Windows API

I have searched the internet for a way to build graphical interfaces for windows without necessarily using the Windows API. I program in C # and for that, I have the WPF solution. However, I could not find any solution in C ++. My goal is...
asked by 24.03.2015 / 04:02
1
answer

Garbage Collector for C ++

I clearly understand what a Garbage Collector is and what a Garbage Collector is for. It is very well known in Java. Is there a library in C ++ that implements GC or fixes memory lLeaks? I have already searched the internet but it always...
asked by 14.12.2015 / 18:28