Last active
November 28, 2018 04:25
-
-
Save kgbook/62c5caa7aa6da93656276b7ffb785284 to your computer and use it in GitHub Desktop.
[inheritance example]inheritance #inheritance #C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
//using namespace std::cout; | |
class Subject | |
{ | |
public: | |
Subject() { | |
std::cout <<__func__ <<"@LINE#" <<__LINE__ <<std::endl; | |
} | |
virtual ~Subject() { | |
std::cout <<__func__ <<"@LINE#" <<__LINE__ <<std::endl; | |
} | |
virtual void doSth() = 0; | |
}; | |
class ClimateSubject : public Subject | |
{ | |
public: | |
ClimateSubject() { | |
std::cout <<__func__ <<"@LINE#" <<__LINE__ <<std::endl; | |
} | |
~ClimateSubject() { | |
std::cout <<__func__ <<"@LINE#" <<__LINE__ <<std::endl; | |
} | |
void doSth() { | |
std::cout <<__func__ <<"@LINE#" <<__LINE__ <<std::endl; | |
} | |
}; | |
int main() { | |
ClimateSubject p; | |
p.doSth(); | |
} | |
// Subject@LINE#9 | |
// ClimateSubject@LINE#23 | |
// doSth@LINE#31 | |
// ~ClimateSubject@LINE#27 | |
// ~Subject@LINE#13 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment