21 lines
746 B
C++
21 lines
746 B
C++
#pragma once
|
|
|
|
class BaseClass {
|
|
protected:
|
|
bool b;
|
|
float f1;
|
|
float f2;
|
|
public:
|
|
virtual void printClassName(); //For a class to be "polymorphic", You *must* have at-least one virtual member.
|
|
virtual ~BaseClass() = default; //If you don't have any reason to have virtual functions, you can make a virtual destructor.
|
|
}; //Virtual has a ton of uses. The *huge* one is the ability to use dynamic cast. -> someFunc.cpp
|
|
|
|
class DerivedClass1 : public BaseClass {
|
|
public:
|
|
void printClassName() override; //Using "Virtual Functions" we "Override" the function inside the base class. -> polymorphicClass.cpp
|
|
};
|
|
|
|
class DerivedClass2 : public BaseClass {
|
|
public:
|
|
void printClassName() override;
|
|
}; |