I need help creating functions for 2 classes (with headers and source files) wit
ID: 3589944 • Letter: I
Question
I need help creating functions for 2 classes (with headers and source files) with an inheritence relationship in c++. The base class is Vehicle and the derived class is Car. The following pictures details how to set up the two classes. I've already created the header files(included here:https://docs.google.com/document/d/1Z869BC0wGInYDTsg6vjFf7AKCNXtgx49hXq3GM-a66s/edit?usp=sharing). Now, I need help with writing the source file functions for the two classes.
memlbere hicle on the cath The Vehicle Class will contain the following protected data members: m_lla, a float array of size 3 which represents the location of the vehicle on the earth (LLA stands for longitude-Latitude-Altitude, which are the 3 values stored within the array). m_vin, a const int which represent a unique VIN - Vehicle Identification Number (no two vehicles can ever exist with the same m_vin) and the following private data members: s_idgen, a static int which is used by the class to generate a unique identifier to initialize m_vin whenever a new Vehicle object is instantiated - how can you achieve this behavior? (Hint Remember how you have been using static variables so far to keep track of the count of a class' active objects) and will have the following public methods: Default Constructor - will leave everything uninitialized (except m_vin which has to follow the above described specifications). When it gets called, it should produce a debug output: "Vehicle #vin: Default-ctor" (where vin the actual member value) Parameterized Constructor - will create a new object based on a desired value for the VIN ssed by-Value (it is however able to assign a different value if it runs into any danger of assigning conflicting values), and a desired set of values for LLA passed by-Address (a pointer to float data). When it gets called, it should produce a debug output: "Vehicle #vin: Parametrized-ctor" (where vin the actual member value) Copy Constructor - will create a new object based on the values of another Vehicle object (except m_vin which has to follow the above described specifications). When it gets called, it should produce a debug output: "Vehicle #vin: Copy-ctor" (where vin the actual member value) Destructor - called whenever an object gets destroyed. When it gets called, it should produce a debug output: "Vehicle #vin: Dtor" (where vin the actual member value).Explanation / Answer
These both class having all member , member function and constructros , distroctor and overloded operators as you want. please go threw code and comments i mentioned.I try with putting in .cpp file it is properly compiling.
class vehical
{
protected: //protected members
float m_lla[3]; //m_lla will can stor 3 floats in side which will you used for location
const int m_vin;
private: // private members
static int sidgen;
public:
vehical(); //Default constructur you can give defination out side
vehical(const int x) ;// perameterised construct
vehical(vehical &obj); //copy constrctor
~vehical() //Distroctur
{
std::cout<<"Vehical "<<m_vin<<":Dtor "<<std::endl;
}
void operator = (const vehical &obj) // assignment operator
{
//change here what ever you want
std::cout<<"Vehicle "<<obj.m_vin<<"Assignment"<<std::endl;
}
const int GetVehicalVin(void); //function for getting vihecal vin
void SetLocation(float []); //function for setting location
void MoveVehical(float []); // function for move methods
int GetIdgen(void); //GetIdget function
void operator << (const vehical &obj); // incertion operator overloading
};
class car : vehical
{
private: //private part
char m_plates[255]; // m_plates which will take upto 255 charater
int m_throttle;
public: //Public part
car(); //constructor
car(char [] , int m_vin); //parameterised constructor
car(car &obj) // copy constructor
{
std::cout<<"Vehical vin: "<<obj.m_vin<<std::endl;
}
~car() //Distroctur
{
std::cout<<"Vehical "<<m_vin<<":Dtor "<<std::endl;
}
void operator = (const car &obj) // assignment operator overloaded
{
//change here what ever you want
std::cout<<"Vehicle "<<obj.m_vin<<"Assignment"<<std::endl;
}
int GetCarThrottle(void); //function for getting car throttle
void SetCarPlates(char []); //function for setting m_plates
void Drive(int); // Drive will take int throttle value
void Move(float []); // function will take float array as an input_iterator
void operator << (const car &obj); // incertion operator overloading
};
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.