Skip to content

Instantly share code, notes, and snippets.

@NightBlues
Last active March 21, 2016 17:52
Show Gist options
  • Save NightBlues/6858db9cb05590a7f078 to your computer and use it in GitHub Desktop.
Save NightBlues/6858db9cb05590a7f078 to your computer and use it in GitHub Desktop.
#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;
}
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