Last active
March 21, 2016 17:52
-
-
Save NightBlues/6858db9cb05590a7f078 to your computer and use it in GitHub Desktop.
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; | |
class A { | |
public: | |
char a; | |
int i; | |
A (int i, char a) { | |
this->i = i; | |
this->a = a; | |
} | |
}; | |
class B { | |
public: | |
int i; | |
char a; | |
B (int i, char a) { | |
this->i = i; | |
this->a = a; | |
} | |
}; | |
int main() { | |
A * var = new A(1, 'a'); | |
cout << "A.i = " << var->i << endl; | |
B * var2 = (B *) var; | |
cout << "B.i = " << var2->i << endl; | |
return 0; | |
} |
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
class A(object): | |
def my1(self): | |
print "my1" | |
class B(object): | |
def my2(self): | |
print "my2" | |
if __name__ == '__main__': | |
obj_name = raw_input() | |
locals()[obj_name]().my1() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment