Question

Step 1: In this experiment you will investigate the implementation for overloading the operator

Step 1: In this experiment you will investigate the implementation for overloading the operator

0 0
Add a comment Improve this question Transcribed image text
Answer #1

int main()
{
      Bank_Acct my_Acct;
      Bank_Acct DrB(2000.87, "Dr. Bullard");    
    
      //This statement executes
        cout<<DrB;
      //This statement will execute and throws errors
      //that parameters for the << operator mismatched
      //Question2: cout<<DrB<<my_Acct<<endl;

      system("pause");
      return 0;

}

// Question 1:Did the program in Step 2 execute without any errors? Make a statement about
// Explanation :
// Yes. The program in step2 executes wihtout any erros because the operator <<
// is overloaded using friend function .
// The << operator overloading gets cout class object and Bank_Acct object
// and prints name and balance of Bank_Acct class on console output .

// Question 2:Replace the cout statement in the main function of the program in Step 2
// with the following statement:
// cout<<DrB<<endl<<my_Acct<<endl;
// Explanation :
// No.The program will not execute because the operator
// << is overloaded for BanK_Acct one object only.
// But the statemet cout<<DrB<<endl<<my_Acct<<endl contains
// two objects . So the program will not execute and throw errors.

Hope this helps you
Note :

In Question 3 , step1 is not provided in the post.

In Question 4 referering Question8 . But Question8 is not provided.

Add a comment
Know the answer?
Add Answer to:
Step 1: In this experiment you will investigate the implementation for overloading the operator
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT