Skip to content

Instantly share code, notes, and snippets.

@jitpaul
Last active April 26, 2018 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jitpaul/878fc96bff69271f3e13b62c0c743717 to your computer and use it in GitHub Desktop.
Save jitpaul/878fc96bff69271f3e13b62c0c743717 to your computer and use it in GitHub Desktop.
TypeCasting
#include <iostream>
using namespace std;
class Base_Class {
public:
virtual void func() {}
};
class Derived_Class :public Base_Class {
public:
void func() {}
};
int main() {
Base_Class * a = new Base_Class();
Derived_Class *b = dynamic_cast<Derived_Class*>(a);
if (!b) cout << "b is nullptr";
else cout << "b is not nullptr";
cin.get();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment