converting base class to dervived class

Reply

Join Date: May 2005
Posts: 2
Reputation: schoolgirl05 is an unknown quantity at this point 
Solved Threads: 0
schoolgirl05 schoolgirl05 is offline Offline
Newbie Poster

converting base class to dervived class

 
0
  #1
Jul 10th, 2005
I would appreciate some input if you don't mind. Can someone please explain to me why converting a base class pointer to a derived class pointer is considered dangerous by the compiler.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,652
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 721
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: converting base class to dervived class

 
0
  #2
Jul 10th, 2005
>Can someone please explain to me why converting a base class pointer to a
>derived class pointer is considered dangerous by the compiler.
It's not "dangerous" as you say, but it does go against the rules of implicit conversions, so conversion without a cast is illegal, and most of the time such a conversion represents a design flaw, so downcasting is discouraged.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC