Hi, please could somebody give some guidance with this C++ question, I have done most of the code I just cant get the program to run.
Q. Create a class called Prompt. Pass a prompting string to a constructor. Have the constructor display the string and then expect the input of an integer. Store this value in a private variable called count. When an object of type Prompt is destroyed, ring the computer bell (output ‘\a’) as many times as the user entered in response to the request for an integer.
#include "Prompt.h" // gives us access to the Prompt class
#include <iostream> // gives us access to simple input and output
usingnamespace std; // don't worry about namespaces yet
void main() {
// dummy variable for pausing the program
string pause;
// create an instance of a rings object
Prompt rings("");
// uses the setter method initialise the rings
rings;
// uses the getter method for accessing accountName
cout << "How many times would you like to ring my bell: \n";
cout << rings.getrings() << endl;
cin >> pause;
}//end of main
May I ask what program do you use to code ? I think I saw a few errors... depending on what developer program you use ... (If you are using either Code::Blocks or BorlandC++ you might be ok, if your using other code program like DevC++ , MinGW, then your code is wrong...)
void main()
This is incorrect and a good compiler will not compiler it. main() returns an int.
You're missing a semi-colon at the end of your class declaration.
You've defined a function double Prompt::rings(void) without having declared it in your class declaration.
Likewise void Prompt::deposit(double amountIn)
In C++, we don't write someFunction(void) - we write someFunction() .
rings = rings;
What exactly is that for?
1 2
// uses the setter method initialise the rings
rings;
This does nothing. It certainly does not call a setter method.
1 2
// create an instance of a rings object
Prompt rings("");
No, it creates an object of Prompt type, named rings. That's a really bad name for the object, given that it contains a variable also called rings. You're just going to confuse yourself.
Create a class called Prompt.
Pass a prompting string to a constructor.
Have the constructor display the string and then expect the input of an integer.
Store this value in a private variable called count.
When an object of type Prompt is destroyed, ring the computer bell (output ‘\a’) (yadda yadda)
¿Why the hell is there a Prompt::deposit() method?
¿What do you need the getters for?
I suppose that rings is the counter variable. ¿Why is it double?
You are doing nothing that you were asked for. The constructor and destructor are empty.
Six hours coding is no joke, especially under the influence of alcohol.
You should have read some theory. Or kick the ball