need hlep please
Apr 11, 2015 at 10:23am UTC
hello everyone, i need your help with this code ,i try to do dynamic_cast just to understand ,is my way corect ?!.cuz doesniot work ,please help me with it, i have exam tomorow.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
#include<iostream>
#include<string>
#include<typeinfo>
using namespace std;
class loli{
protected :
string name;
int id;
public :
loli(string n,int i){
id=i;
name=n;
}
virtual string getname(){cout<<name;
return name; }
virtual int getid(){cout<<id;
return id;}
};
class pop:public loli{
public :
pop(string n,int i):loli(n,i){}
string getname(){cout<<name;
return name; }
int getid(){cout<<id;
return id;}
};
class doll:public pop{
public :
doll(string n,int i):pop(n,i){};
string getname(){
cout<<name;
return name; }
int getid(){cout<<id;
return id;}
};
int main(){
pop p("dona" ,322);
doll d("jdakj" ,3423);
loli *lol1=&p;
loli *lol2=&d;
lol1->getid();
lol1->getname();
cout<<endl;
lol2->getid();
lol2->getname();
dynamic_cast <loli*>(doll);
typeid (pop).name();
system ("pause" );
return 0;
}
thank you
Apr 11, 2015 at 12:25pm UTC
please i need your help
Apr 11, 2015 at 2:42pm UTC
dynamic_cast <loli*>(&d);
Topic archived. No new replies allowed.