[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

C++ klass typer.



Hej !

Jag undrar om det är möjligt att i C++ ta reda på vad klass X är för typ ?

Det är som så att jag har följande:

class A {
public:
  void print(void) = 0;
};

class B : public A {
public:
  void print(void) { cout << "Hello World" << endl; };
}

class C : public A {
public:
  void print(void) { cout << "BSOD again he !!" << endl; };
}

int main(void) {
  A *ap = NULL;
  ap = new B;
  b->print();
  delete ap;
  ap = new C;
  ap->printf();
  delete ap;
 return 0;
}

Hade velat kunan ta reda på om ap är en klass C eller B.

/Jocke!



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *