Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Casting using typedef???

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I`m trying to cast a parent class to a child class using the typedef as a variable when casting but it comes up with the error, that it "expects a type def (typedef) when found a Shape":

// circle is a class
typedef Circle def;

// shape is a parent class for a child circle class
vector<Shape> Vec;

Shape shape1();

vec.push_back(shape1);
((def)shape1).data = &quot;hello&quot;;
 
Hi!
dynamic_cast Used for conversion of polymorphic types

For instance:
class A {
}

class B:public class A{
}

...
A a;
B b
a = dynamic_cast<A>(b);

Best regards,
Eugene Doronin.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top