Welcome! Log In Create A New Profile

Advanced

Assignment3 Qu1

Posted by VeerVortex 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Assignment3 Qu1
June 09, 2007 03:01PM
In this question they ask me to use a input function with a single parameter of type istream, but if i do that, how do i invoke my second constructor based on what the user enteres in Input().

Should i not also include a reference to my class object i decalred in main()
within the parameters of Input() so that i may invoke my second construtor:

FOR EXAMPLE


int main()
{
CDAccount account; //this should use the default constructor and set my
//private member variables to 0, but i want to
//update this inside Input() to make it invoke the
//second constructor

account.Input(cin, account) //Can this be done for this question
//this way

return 0;

}

//IMPLEMNETATION

void CDAccount:sad smileyistream &cin, CDAccount &account)
{
//GET VALUES FOR RANDS, CENTS, TERM, RATE

//NOW ASSIGN THOSE VALUES AFTER CHECKING THAT THEY ARE CORRECT TO INVOKE
//MY SECOND CONSTRUCTOR AS FOLLOWS

account = CDAccount(RAND,CENT,TERM,RATE);

}

IS MY THINKING TOTALL OUT ON THIS OR NOT AND COULD SOME1 SUGGEST HOW I COMBAT THIS DIFFICULTY IM HAVING.SHOULD THE CLASS BE DECALRED INITIALLY AS IT WAS ABOVE?

thank you
Re: Assignment3 Qu1
June 09, 2007 03:45PM
does the ? want me to decalre a class object with any values i specifiy, like for example:

int main()
{
CDAccount account(100,20,5.0,2) //RAND,CENT,RATE,TERM
}

Im having difficulty understanding whether we must specify a value or have a user do it for us within Input()
Re: Assignment3 Qu1
June 12, 2007 07:32AM
Make your input member function be of type CDAccount. In your input function create an object of the CDAccount class as well as return this populated object to the calling statement(where you would have declared an object of the CDAccount class)

Like you've probably figured...you must do the input from your input class using the passed parameter of istream type and pass these values when you're instantiating this object.

Good luck!
Sorry, only registered users may post in this forum.

Click here to login