Let's say i have two class named Object (base class) and an actor class (derived class). The actor class uses physics so i need to implement it on the Actor class. But there are other derived class of the "Object" class that don't use physics so i don't want to have physics implemented on them because it would be useless data.
class Object
{
public:
Object();
~Object();
virtual void Main();
private:
Transform transform;
};
class Actor : public Object
{
public:
Actor();
~Actor();
void Main();
private:
Physics physics; //Can i make this????
};
Because i only implemented physics on the actor class i need to upcast it from some way to the base class like this:
int main()
{
Object* BaseClass = new Actor;
}
Is the "physics" data, defined on the actor, allowed to be upcasted even if i don't want to use it externally? There isn't any way i can make it?