Question: Goals: Write a program using C + + inheritance to explore how to create and use C + + classes and subclasses. Description: Write a
Goals: Write a program using C inheritance to explore how to create and use C classes and subclasses.
Description: Write a C program with the following classes:
in a file called Coordinate.h define a purely virtual class ie one with no implemented methods called Coordinate that represents an abstract dimensional coordinate. Your class must have a pure virtual method called ToString that returns a string representation, and may have a virtual nonabstract destructor if needed.
in files Cartesian.h and Cartesian.cc create a subclass of Coordinate called Cartesian that represents a D cartesian coordinate ie one with x and y values of type double Implement ToString, and also add a method called Distance that calculates the distance between the object and a second Cartesian point object passed by reference as an argument.
in files Polar.h and Polar.cc create a subclass of Coordinate that represents a D polar coordinate ie one with a radius and angle of type double Implement ToString and also add a method called Distance that calculates the distance between the object and a second Polar object.
in file excc write a main function that tries out your classes.
Create a suitable Makefile. The command make should build an executable program ex recompiling individual files only when needed. The command make clean should remove the ex executable, all o files, and any editor or other backup files whose names end in ~
Hint: The std::stringstream class can be useful for implementing the ToString methods. It supports writing values to a string with the stream output operator.
Your code must:
compile without errors or warnings on CSE Linux machines lab workstations, attu, or CSE home VM
have no crashes, memory leaks, or memory errors on CSE linux machines
have a Makefile as described above that compiles the code with the g options Wall g stdc
be pretty: the formatting, modularization, variable and function names, use of const and so on must make us smile rather than cry. Hints: Google C Style Guide, cpplint
have a comment at the top of each source file with your name, and CSE or UW email address.
You should submit your exercise using the Gradescope dropbox linked on the course resources web page.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
