I'm trying to pass a variable from parent class to it's child class. The code does compile, but keeps giving me the result; 0. When I hardcode the value in the base constructor inside the child class, it does give me the wanted result.
Parent class.h:
class Parent{
float price;
public:
Parent(float price)
}
Parent class.cpp:
#include "Parent.h"
Parent::Parent(float price){
this->price = price;
}
Child class.h:
class Child : Parent{
const float price = 0.29;
public:
Child();
}
Child class.cpp:
#include "Child.h"
Child::Child() : Parent(price){
}
How can I make it so the var inside the child class can be used in the constructor of the base class?