[ create a new paste ] login | about

Link: http://codepad.org/3fFEuUbU    [ raw code | output | fork ]

C++, pasted on Jul 13:
#include <iostream>
#include <typeinfo>
using namespace std;

class Base{
	virtual void func() {}
};

class Derived: public Base{
	virtual void func() {}
public:
	int i;
	Derived(int j){i=j;};
}
;
void WType(Base &ob){
	cout<<typeid(ob).name()<<endl;
}

int main(){
	Base a1;
	Derived b1(1);
	WType(a1);
	WType(b1);
}


Output:
1
2
4Base
7Derived


Create a new paste based on this one


Comments: