Inheritance


here is the link for the zoom interactive lab it will be available at 5:30 to 7:00
on monday and wednesday

https://csub.zoom.us/j/92095637957?pwd=ZER6WU9qakJLS0Naek5aSlpMUlBiZz09






Video
You will create a Square and a Triangle Class, Triangle is a child class of Square there is a main , Makefile and class files provided for you put your class defenitions in the .h files and your function bodies in the .cpp files your classes will be as follows File: Square.h

#pragma once
#include "cmpslib19.h"
#include "easylogging++.h"

// start your square class
// put the bodies of the functions in the Square.cpp file
    // the Square class will contain

    // data members
  protected:
    double length;


    // functions
  public:
    Square();
    /* set length to 0 */


    Square(double);
    /* set length to parameter, use your function to SetLength so it has the logic to ensure it is 
       a legitimate value  ( you dont want the same logic in more than one place) */


    ~Square();
    /* just log start & end */


    void SetLength(double);
    /* set length to value passed in , if value is less than zero set length to 0 */


    double Area();
    /* return the area,  (length * length) */


    string ToString();
    /* return a formatted string like the example */


// end your square class, dont forget the trailing ;





File: Triangle.h


#pragma once
#include "cmpslib19.h"
#include "easylogging++.h"
#include "Square.h"
// start your Triangle class
// put your function bodies in the Triangle.cpp file 
    // the Triangle class will contain

    //data members
  protected:
    double height;

    //functions
  public:/**/
    Triangle();
    /* set height to 0 ( use SetHeight  ), length should be set in Square constructor */


    Triangle(double, double);
    /*
    set length to value one passed in
    set height to value two passed in
    use SetLength (inherited from Square)  and SetHeight
    */


    ~Triangle();
    /* just log start & end */

    void SetHeight(double );
    /*
      this is a an additional function that the square class did not have 
			set height to value passed in , if value is less than zero set height to 0 */


    double Area();
    /* return the area,  ( 5. (length * height)) 
       we are overriding the Area function of the Square class as we need it to be different as
       the formula to calculate the area of a Triangle is different from that of a Square
    */

    string ToString();
    /* return a formatted string like the example */
// end of Triangle class , dont for get trailing ;


------------------------------------------------------------------------------