T
Tommy Lang
Hi !!
I am a c++ novice and I would appreciate any help with the following:
I have created a class called "Number". In the main function of my
program I call the class constructor twice like this(at start up)...
int main(){
Number no1;
Number no2;
.......
Everything is fine so far.
Then in the class constructor I want to ask for two numbers and add
them to the private member variables m_no1 and m_no2...
Number::Number()
{
if (first_time) //first-time is a private boolean variable (how to
init it??)
{cout << "Enter number: ";
cin >> m_no1; cin.get();}
else
{cout << "Enter next number: ";
cin >> m_no2; cin.get();}
}
I have tried this approach but I couldn't get it to work properly. And
when I got it to work it NEVER got to the else statement. First time I
want to get m_no1 next time m_no2. Any pointers???
Thanks,
Thomas
I am a c++ novice and I would appreciate any help with the following:
I have created a class called "Number". In the main function of my
program I call the class constructor twice like this(at start up)...
int main(){
Number no1;
Number no2;
.......
Everything is fine so far.
Then in the class constructor I want to ask for two numbers and add
them to the private member variables m_no1 and m_no2...
Number::Number()
{
if (first_time) //first-time is a private boolean variable (how to
init it??)
{cout << "Enter number: ";
cin >> m_no1; cin.get();}
else
{cout << "Enter next number: ";
cin >> m_no2; cin.get();}
}
I have tried this approach but I couldn't get it to work properly. And
when I got it to work it NEVER got to the else statement. First time I
want to get m_no1 next time m_no2. Any pointers???
Thanks,
Thomas