Question
Problem 1. 1. Create a new C++ project, named hw3. 2. Design a class Shape that stores x and y coordinates of a shape. Write
Problem 1. 1. Create a new C++ project, named hw3.
2. Design a class Shape that stores x and y coordinates of a shape. Write the classdeclaration in the header file (.h) and the class definition in the implementation
file (.cpp). Your class must have the following public methods: constructor with two arguments for x and y draw prints statement, such as drawing a shape with coordinates (2.3) print prints statement, such as this is a shape with coordinates (2.3)
3. Create a main.cpp source file with int main() function.
4. Write test code to create three objects of type Shape. Call both draw and print
method on each object.
5. Create pointers for each of your three objects.
6. Call both draw and print function on each object using these pointers with the ->operator.Your program should produce an output similar to the following:
calling the draw() function:
drawing a shape with coordinates (10, 24)
drawing a shape with coordinates (4, 2)
drawing a shape with coordinates (-5, 8)
calling the print() function:
printing a shape with coordinates (10, 24)
printing a shape with coordinates (4, 2)
printing a shape with coordinates (-5, 8)
USING POINTERS:calling the draw() function:
drawing a shape with coordinates (10, 24)
drawing a shape with coordinates (4, 2)
drawing a shape with coordinates (-5, 8)
calling the print() function:
printing a shape with coordinates (10, 24)
printing a shape with coordinates (4, 2)
printing a shape with coordinates (-5, 8)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started