Questions tagged as 'c++'

3
answers

What is the difference between delete vs delete [] vs free (...)

I am learning C ++ and I find that there are different ways to free dynamic memory ( delete , delete[] , free(...) ) and I do not know what cases to use them, can someone get me out of this confusion? Thanks beforehand     
asked by 25.09.2018 / 00:40
2
answers

Cube dice roll

I need a program that does the following: Toss two dice (between 1 and 6). If the value is the same, launch them again. Print the total number of boxes the player is advancing Next I have the code; however, I can not find a func...
asked by 17.04.2018 / 19:24
2
answers

Inheritance in C ++ and problems with reboot variations ()

First I use C ++ 11 . I have a base class called Area that has an undefined pure virtual function called restart (). Then I have two derived classes, one called AreaRectangular and another called AreaCircular . The problem is that th...
asked by 06.04.2018 / 20:53
1
answer

Access, read and write c ++ files [closed]

I was working java and I used Scanner to access the content of text files, and also Printstream to write in new files, what would be the analogous way to perform these actions in c ++? for example, in java: public Class(Scanner sc) { w...
asked by 01.06.2018 / 03:12
3
answers

Give access to a class to a private member of another class

I have a class to call class A that contains an object of class B . class A{ B objeto_b; }; I need that A can access a private method of class B . Why do I want it to be private then? Because that method I only w...
asked by 10.04.2018 / 19:24
3
answers

Doubt with arrays in C ++

I'm working with C ++ and a teacher told us in class that we can not tell an array to measure a variable int array[i]; But for example can I create a constant and tell it to measure a variable to put the constant in the array? #define con...
asked by 31.10.2017 / 19:11
2
answers

I would like to see a value of a decimal without C ++ being rounded

I need help with a code in C ++, the exercise asks me to do a calculation, if the result is, for example 1.57, in the output it should show 1.5, (the variable can be float or double) without making the rounding. #include <iostream> #incl...
asked by 07.08.2017 / 19:31
2
answers

Overloading an external operator

I am overloading the operator + externally. It is obvious that if I put: Fraccion operator+ (const Fraccion& r1, const Fraccion& r2) { Fraccion res; res.numerador = r1.obtenerNum() + r2.obtenerNum(); res.denominador = r1.obtener...
asked by 27.03.2018 / 12:34
2
answers

Show value of a struct

I'm having a problem that is probably silly but I do not understand why it does not work despite its simplicity. Having a struct composed of the components of a vector in 3D, I only wanted to show one of them after I typed it and yet i...
asked by 23.01.2018 / 13:46
1
answer

Use a space or "" as an element of a string in c ++

I want to have a space as an element of a string in c ++ this is my code: #include <iostream> #include <string.h> using namespace std; int main(){ int n; cin>>n; cin.ignore(); int cont=1; while(n--){ cout<<"Mess...
asked by 31.03.2018 / 06:40