Question

Which of the following operator functions are legal?    For those not legal, indicate why not. a....

Which of the following operator functions are legal?

   For those not legal, indicate why not.

a. Complex Complex::operator+(const Complex& a) const {...}

b. Clock Clock::operator++(int) {...}

c. Menu Menu::operator++(const Menu& a, const Menu& b) {...}

d. Menu Menu::operator**(const Menu& a) const {...}

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

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

OPTIONS A,B AND C ARE VALID BUT, D IS NOT VALID SINCE we can't overload ** operator in cpp

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Which of the following operator functions are legal?    For those not legal, indicate why not. a....
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
  • I need help with those two functions c++ #ifndef TRIPLE_H #define TRIPLE_H #include <iostream> #include <string>...

    I need help with those two functions c++ #ifndef TRIPLE_H #define TRIPLE_H #include <iostream> #include <string> using namespace std; class Triple { private: int a, b, c; public: Triple(); // all elements have value 0 Triple(int k); // all elements have value k Triple(int x, int y, int z); // specifies all three elements Triple(string s); // string representation is "(a,b,c)" string toString(); // create a string representation of the vector void fromString(string s); // change the vector to equal...

  • for C++ 10.) (8) Indicate which of the following assignment statements are legal if x is...

    for C++ 10.) (8) Indicate which of the following assignment statements are legal if x is an int variable and y is a float variable. Show what is stored in the receiving variables if the statement is correct: а, у х: c. y (float) x; d. x (int) y r++ A homeowner would like to calculate the idla of a rectangle

  • This is for c++ Implement the following overloading operator functions: Matrix (int rowSize, int colSize); ~Matrix...

    This is for c++ Implement the following overloading operator functions: Matrix (int rowSize, int colSize); ~Matrix (); Matrix operator + (Matrix & m); Matrix operator += (Matrix & m); Matrix operator += (const int &num); Matrix operator * (Matrix & m); Matrix operator ++(); friend Matrix operator +(const int &num, const Matrix &m); friend istream& operator>> (istream& in, const Matrix& m); friend ostream &operator<<(ostream &os, const Matrix &m); Test your Matrix class withe following main function: cout << "Matrix 1:"...

  • 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...

  • Design a class Complex for handling Complex numbers and include the following: _ real: a double...

    Design a class Complex for handling Complex numbers and include the following: _ real: a double _ imaginary: a double The class has the following member functions. a. A constructor initializing the number with default parameters. b. Getters and Setters of the class data members as given below _ void setReal(double r) _ double getReal()const _ void setImaginary(double i) _ double getImaginary() const d. Overload unary ! operator which returns true if the real and the imaginary parts are zero,...

  • Please answer all the questions thank you 1) (Classes – 20 Points) Consider the following class...

    Please answer all the questions thank you 1) (Classes – 20 Points) Consider the following class declaration for Time to complete the questions below: DO NOT WRITE MORE THAN ASKED FOR. class Time private: int hours; int minutes; public: Time(); Time (int , int m = 0); void addMin(int m); void addHr(int h); void reset(int h = 0, int m = 0); Time operator+(const Time & t) const; Time operator-(const Time & t) const; Time operator*(double n) const; friend Time...

  • USING C++: Referring to the header file below named coord2d.h, Implement each of the 8 operator...

    USING C++: Referring to the header file below named coord2d.h, Implement each of the 8 operator overloads (operators: <<, [], >, <, two versions of +, two versions of *) #ifndef COORD2D_H #define COORD2D_H #include <iostream> using namespace std; //implement a class that keeps track of the coordinates of a point in the X-Y plane class coord2d { //overload the << operator so that if p is of type "coord2d" then "cout<<p"; //will print out (x_coord, y_coord) //e.g. if p.x_coord=3.4,...

  • USING C++ Consider class Thing t string secretName unsigned mschiefLevel:; public: ThingO ...) Thing( const Thing &t)(·.) // Assume these three // member functions const Thing &operator-(...

    USING C++ Consider class Thing t string secretName unsigned mschiefLevel:; public: ThingO ...) Thing( const Thing &t)(·.) // Assume these three // member functions const Thing &operator-(.. -ThingO are properly class CatInTheHat Thing thing_1; Thing thing 2; Thing "seuss; /points to an array of suessize Things unsigned suessize; public: There isn't enough info here to write this, so I'm not asking. CatInTheHat( const CatIn TheHat &cat); const CatInTheHat &operator-(const CatInTheHat &cat); CatInTheHat0; 5) Write the CatInTheHat copy constructor. (2 pts...

  • I only need the "functions" NOT the header file nor the main implementation file JUST the impleme...

    I only need the "functions" NOT the header file nor the main implementation file JUST the implementations for the functions Please help, if its difficult to do the complete program I would appreciate if you could do as much functions as you can especially for the derived class. I am a beginer so I am only using classes and pointers while implementing everything using simple c++ commands thank you in advanced Design and implement two C++ classes to provide matrix...

  • Consider this declaration of the class Fraction: class Fraction { private: int numerator, denominator; public: Fraction...

    Consider this declaration of the class Fraction: class Fraction { private: int numerator, denominator; public: Fraction operator+(const Fraction & frac2); Fraction & setNumerator(int numer); Fraction & setDenominator(int denom); }; a. Why is there only one parameter, frac2, used with operator+, even though addition has two operands? b. Write the operator: Fraction Fraction::operator+ (Fraction frac2){ } c. Write setNumerator() and setDenominator() as cascading functions: Fraction & Fraction::setNumerator(int numer) { } Fraction & Fraction::setDenominator(int denom) { } d. Assign the fractions frac1...

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