Question

In c++ Consider the following declaration: class strange { . . . }; Write a statement...

In c++ Consider the following declaration:

class strange
{
.
.
.
};

Write a statement that shows the declaration in the class strange to overload the operator >>.

Write a statement that shows the declaration in the class strange to overload the operator =.

Write a statement that shows the declaration in the class strange to overload the binary operator + as a member function.

Write a statement that shows the declaration in the class strange to overload the operator == as a member function.

Write a statement that shows the declaration in the class strange to overload the post-increment operator ++ as a member function.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
class strange
{
    // Write a statement that shows the declaration in the class strange to overload the operator >>.
    friend istream &operator>>(istream &in, strange &s);

    // Write a statement that shows the declaration in the class strange to overload the operator =.
    strange &operator=(const strange &s);

    // Write a statement that shows the declaration in the class strange to overload the binary operator + as a member function.
    strange operator+(const strange &s);

    // Write a statement that shows the declaration in the class strange to overload the operator == as a member function.
    bool operator==(const strange &s);

    // Write a statement that shows the declaration in the class strange to overload the post-increment operator ++ as a member function.
    strange &operator++();
};
Add a comment
Know the answer?
Add Answer to:
In c++ Consider the following declaration: class strange { . . . }; Write a statement...
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
  • Write a statement that declares sObj to be an object of type strange such that the...

    Write a statement that declares sObj to be an object of type strange such that the private member variables a and b are of type int. Write statement that shows the the declaration in the class strange to overload the operator == as a member function. Assume that two objects of type strange are equal if their corresponding member variables are equal. Write the definition of the function operator== for the class strange, which is overloaded as a member function....

  • Can someone explain these terms to me in C++? Thanks 1. Templates: 2. Function: 3. Template...

    Can someone explain these terms to me in C++? Thanks 1. Templates: 2. Function: 3. Template Instantiation: 4. Overload operators: 5. This pointer: 6. Binary operator: 7. Friend function: 8. Overloading post increment operator: 9. Type: 10. Class Templates:

  • Write a C++ class named CashRegister. The class should have private data members named Hundreds, Tens,...

    Write a C++ class named CashRegister. The class should have private data members named Hundreds, Tens, Fives, and Singles all of type integer. The class should have the following: 1. A member function named GetTotalCash to retrieve the total cash inside the cash register. 2. Overload the + operator to allow adding two objects of type CashRegister (note, add the hundreds to the hundreds, tens to tens and so on). 3. Overload the > operator to compare between two CashRegisters...

  • C++ This chapter uses the class rectangleType to illustrate how to overload the operators +, *,...

    C++ This chapter uses the class rectangleType to illustrate how to overload the operators +, *, ==, !=, >>, and <<. In this exercise, first redefine the class rectangleType by declaring the instance variables as protected and then overload additional operators as defined in parts 1 to 3. Overload the pre- and post-increment and decrement operators to increment and decrement, respectively, the length and width of a rectangle by one unit. (Note that after decrementing the length and width, they...

  • Question 14 4 pts Which of the following is the general syntax of the function prototype...

    Question 14 4 pts Which of the following is the general syntax of the function prototype to overload the post-increment operator as a member function? className operator++ 0); friend className operator++(); className operator++ (int): friend className operator ++ (int); Question 15 4 pts Which of the following is a built-in operation on classes? increment assignment decrement relational Question 16 4 pts A friend function can only be a regular stand-alone function and can not be a member of another class....

  • C++ Questions. Question 1 What would the function prototype in the class declaration for the following...

    C++ Questions. Question 1 What would the function prototype in the class declaration for the following member function look like? void Fractions::showData() { if((num < 0 && denom < 0) || denom < 0) { num = -num; denom = -denom; } cout << num << "/" << denom << endl; } Question 2 What would the function header of the following member function prototype in class Fractions be? Fractions operator+(const Fractions &f2); Question 3 What would the function prototype...

  • Write a class declaration section for each of the following specifications. Include a prototype for a...

    Write a class declaration section for each of the following specifications. Include a prototype for a constructor and a member function named showData() that can be used to display data member values. a. A class named Time that has integer data members named secs, mins, and hours b. A class named Date that has integer data members named month, day, and year c. A class named Circle that has integer data members named xcenter and ycenter and a double-precision data...

  • use C++ Based on the class declaration below, write out the declaration of its default constructor....

    use C++ Based on the class declaration below, write out the declaration of its default constructor. class BankAccount { public: BankAccount(); // Sets balance to o BankAccount(double initial_balance); // Sets balance to initial_balance // Member functions omitted private: double balance;

  • A. (C++) Write a class declaration named Circle, with a private member variable, radius. Write set...

    A. (C++) Write a class declaration named Circle, with a private member variable, radius. Write set and get functions to access the radius variable, and a function named get getArea which returns the area of the circle. The area is calculated as 3.14 * radius * radius. B. Write a constructor to the circle that accepts an argument and assign its value to the radius member variable. C. Add a static member variable that accounts for the currently active circle...

  • solve it in c++10 Create a composition between the classes Job and Salary. Class Salary a....

    solve it in c++10 Create a composition between the classes Job and Salary. Class Salary a. data member:    1. money b. constructors:    1. default constructor    2. user defined constructor with a parameter to set money c. standard accessor and mutator functions Class Job a. data members:    title (name of the job)    salary (object of type Salary) b. constructors:    1. default constructor    2. user defined constructor to set title and salary    3. implement constructor delegation c. standard accessor and mutator function...

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