Advertisement

A question on Classes

Started by March 11, 2001 01:29 PM
1 comment, last by Harvester 23 years, 10 months ago
Assume that i have two classes class A; class B:public A; and i take a pointer later on, such as... B b; A* a=&b Obviously, i can go move from the outter class to the inherited classes. However, how can i do the reverese? that would be: B *bb=a; in a few source it looks like this...
  
class A{
  int i1;
}

class B:public A{
  int i2;
}

void main(){
  B cB;
  A *cA=&cB

  //The line that troubles me...

  B *cBB=cA;
}
  
Obviously this will produce an error. I''m sure there must be some macro or something that can get me back to the ''child'' class. Any ideas? thanks
... LEMMINGS ... LEMMINGS ... LEMMINGS ... LEM..... SpLaSh!...Could this be what we stand like before the mighty One?Are we LeMmIngS or WhAt!? ;)
    class A{  int i1;}class B:public A{  int i2;}void main(){  B cB;  A *cA=&cB  //The line that troubles me...  B *cBB=dynamic_cast<B*>(cA);}   


Magmai Kai Holmlor
- The disgruntled & disillusioned
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
thanks
... LEMMINGS ... LEMMINGS ... LEMMINGS ... LEM..... SpLaSh!...Could this be what we stand like before the mighty One?Are we LeMmIngS or WhAt!? ;)

This topic is closed to new replies.

Advertisement