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
  • (1) Declaration and implementation of complex class, overloading operator +, -, != , /, --(prefix), --(postfix)...

    (1) Declaration and implementation of complex class, overloading operator +, -, != , /, --(prefix), --(postfix) as friend functions.         (2)The program should be in Separating Class Specification, Implementation(complex.h,complex.cpp), and Client Code(Task2.cpp).             (3) Run the program and capture screenshots of output. Declaration and implementation of complex class, overloading operator +, -, != , /=, --(prefix), --(postfix) as friend function */ #include "Complex.h" #include <iostream> using namespace std; int main(){       Complex c1(5, 4), c2(2, 10), c3;       cout <<...

  • Programming Question 4: Operator Overloading [20 marks] The class SpecialArray represents an arra...

    C++ please Programming Question 4: Operator Overloading [20 marks] The class SpecialArray represents an array of integers. The class contains two data members: array (of type int"), which represents the array of integers, and size (of type int) that represents the size of the array. The class SpecialArray also overloads the following operators: operator: Compares two arrays. An array "A" is smallerhan an array "B" if the size of array "A" is smaller than the size of "B", or if...

  • Identify the database system that allows for polymorphism of operations or operator overloading

    Identify the database system that allows for polymorphism of operations or operator overloading

  • [COSC29-SLO2+SLO7+SLO8] Write an operator overloading function for the Character class that overloads the '!='operator. class Character...

    [COSC29-SLO2+SLO7+SLO8] Write an operator overloading function for the Character class that overloads the '!='operator. class Character { char v = ; public: Character(char v) { this->v = v; } // overloads the != operator }; BIVA - A - I EX 1 XX, EE - V GT 12pt Paragraph

  • In c++ What does operator overloading allow us to do ? Why must the << and...

    In c++ What does operator overloading allow us to do ? Why must the << and the >> operators be overloaded as friend functions instead of member functions, for a user defined class ? What is the difference between an instance member variable and a static member variable ? How are call to static member functions made ? Describe the difference between reading a file using the >> operator and with the getline function What is inheritance What is a...

  • C++ What would be the proper function prototype of overloading the + operator of a Cat...

    C++ What would be the proper function prototype of overloading the + operator of a Cat class? O const Cat operator+ (Cat right) O const Cat operator+ (const Cat &right) O const Cat ++(const Cat right) O const Cat +-(const Cat &right)

  • Start by using the starter code provided for the Line class. It implements operator overloading so...

    Start by using the starter code provided for the Line class. It implements operator overloading so you can use cin/cout with line objects. A line will be made up of two points. Create an object to implement a “line” class which allows the programmer to store a line. This class must use the “point” class developed in Part B. The object should have two constructors, appropriate set/get functions, and overloaded I/O (cin/cout) functions. It should include functions the return the...

  • Project 1 - Operator Overloading (FlashDrive 2.0) In C++, many of the keyboard symbols that are...

    Project 1 - Operator Overloading (FlashDrive 2.0) In C++, many of the keyboard symbols that are used between two variables can be given a new meaning. This feature is called operator overloading and it is one of the most popular C++ features. Any class can choose to provide a new meaning to a keyboard symbol. Not every keyboard letter is re-definable in this way, but many of the ones we have encountered so far are like +, -, *, /,...

  • Task 1 The purpose of this practical is to examine more complex types of operator overloading...

    Task 1 The purpose of this practical is to examine more complex types of operator overloading in the context of two classes. 2.1.1 Ingredient The ingredient class consists of two files: ingredient.h and ingredient.cpp. The class has the following definition: ingredient -name:string -price:double -weight:int ---------------- +ingredient(n:string,p:double,w:int) +~ingredient() +friend operator<<(output:ostream &,t:const ingredient &):ostream & +getName():string +getPrice():double +getWeight():int The class variables are as follows: • name: the name of the ingredient • price: the base price for each ingredient • weight: the...

  • Given two complex numbers, find the sum of the complex numbers using operator overloading. Write an...

    Given two complex numbers, find the sum of the complex numbers using operator overloading. Write an operator overloading function     ProblemSolution operator + (ProblemSolution const &P) which adds two ProblemSolution objects and returns a new ProblemSolution object. Input     12 -10      -34 38     where, Each row is a complex number. First element is real part and the second element is imaginary part of a complex number. Output     -22 28 Two complex numbers are 12-10i and -34+38i. Sum of complex numbers are =...

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