Question: Implement in C++ language. Run it and show the screenshot. Write comments to understand the functionality. Make it simple Homework 2: C++ classes Create a

Implement in C++ language. Run it and show the screenshot. Write comments to understand the functionality.

Make it simple

Homework 2: C++ classes

Create a class representing anything you like.

  • Separate the header and implementation files.
  • Include a few member variables, including at least one composite type (such as std::string or std::vector)
  • Create a default constructor
  • Create a constructor that requires only one parameter
  • Use member initialization lists for both constructors
  • Overload the + operator for your class
  • Overload the << operator for your class as a non-member function and make the function a friend within your class.
  • Create a method for your class that is const qualified.

Create main.cpp to demonstrate use of your class.

  • Create an instance of your class using the default constructor. Add a comment to the statement that says "Calling the default constructor".
  • Create three more instances of your class using functional form, assignment initialization, and uniform initialization.
  • Use the overloaded + operator to add two instances of your class together.
  • Use the overloaded << operator to print an instance of your class to the console.

Note: Just make a one simple class separate the header file and test your class in the main. Follow the above requirement .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!