Click here to Skip to main content
15,914,165 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Quick way to generate C++ files from an IDL file Pin
Steve S3-Oct-06 6:04
Steve S3-Oct-06 6:04 
QuestionGetting HTML Eevents [modified] Pin
georgekjolly2-Oct-06 3:19
georgekjolly2-Oct-06 3:19 
AnswerRe: Getting HTML Eevents Pin
Stephen Hewitt2-Oct-06 6:00
Stephen Hewitt2-Oct-06 6:00 
GeneralRe: Getting HTML Eevents Pin
georgekjolly2-Oct-06 20:23
georgekjolly2-Oct-06 20:23 
Questionerror in compiling WTL Pin
manish19821-Oct-06 12:54
manish19821-Oct-06 12:54 
AnswerRe: error in compiling WTL Pin
Stuart Dootson1-Oct-06 20:43
professionalStuart Dootson1-Oct-06 20:43 
QuestionMultiple inheritance and class pointer Pin
Samy_Ibraheem_Mo30-Sep-06 9:46
Samy_Ibraheem_Mo30-Sep-06 9:46 
AnswerRe: Multiple inheritance and class pointer Pin
Stuart Dootson30-Sep-06 11:56
professionalStuart Dootson30-Sep-06 11:56 
The example below shows two base classes (A and B) and a class that derives from them both (C). Now, you can cast a C* pointer to A* or B* with static_cast. This will call non-virtual methods on A or B respectively. However, for virtual methods, you need to explicitly ask for the parent classes version, as shown in the comments.

So...to get what you want, you don't actually need a cast at all - just specify that you want to call the parent classes method using the class-name:: notation.

#include <iostream>

class A
{
public:
   void M() { std::cout << "A::M - this = " << (int)this << "\n"; }
   virtual void X() { std::cout << "A::X - this = " << (int)this << "\n"; }
};

class B
{
public:
   void N() { std::cout << "B::N - this = " << (int)this << "\n"; }
   virtual void Y() { std::cout << "B::X - this = " << (int)this << "\n"; }
};

class C : public A, public B
{
public:
   void M() { std::cout << "C::M - this = " << (int)this << "\n"; }
   void N() { std::cout << "C::N - this = " << (int)this << "\n"; }
   virtual void X() { std::cout << "C::X - this = " << (int)this << "\n"; }
   virtual void Y() { std::cout << "C::Y - this = " << (int)this << "\n"; }
};

int main(int, char**)
{
   C c;
   
   // Call C::X through C
   c.X();
   // Call A::X through C
   c.A::X();
   // Call C::X through A*
   static_cast<A*>(&c)->X();
   // Call A::X through A*
   static_cast<A*>(&c)->A::X();
   
   // Call C::M through C
   c.M();
   // Call A::M through C
   c.A::M();
   // Call A::M through A*
   static_cast<A*>(&c)->M();
   // Call A::M through A*
   static_cast<A*>(&c)->A::M();

   // Call C::Y through C
   c.Y();
   // Call B::Y through C
   c.B::Y();
   // Call C::Y through B*
   static_cast<B*>(&c)->Y();
   // Call B::Y through B*
   static_cast<B*>(&c)->B::Y();
}

QuestionDrawing Pin
Demian Panello27-Sep-06 6:24
Demian Panello27-Sep-06 6:24 
AnswerRe: Drawing Pin
led mike28-Sep-06 5:42
led mike28-Sep-06 5:42 
GeneralRe: Drawing Pin
Demian Panello3-Oct-06 4:27
Demian Panello3-Oct-06 4:27 
AnswerRe: Drawing Pin
Jörgen Sigvardsson30-Sep-06 15:03
Jörgen Sigvardsson30-Sep-06 15:03 
GeneralRe: Drawing Pin
Demian Panello3-Oct-06 4:24
Demian Panello3-Oct-06 4:24 
Question[SOS]Winsock in ATL Dll [SOS] Pin
Eytukan26-Sep-06 23:17
Eytukan26-Sep-06 23:17 
AnswerRe: [SOS]Winsock in ATL Dll [SOS] Pin
led mike28-Sep-06 5:39
led mike28-Sep-06 5:39 
GeneralRe: [SOS]Winsock in ATL Dll [SOS] Pin
Eytukan28-Sep-06 6:32
Eytukan28-Sep-06 6:32 
GeneralRe: [SOS]Winsock in ATL Dll [SOS] Pin
led mike28-Sep-06 6:52
led mike28-Sep-06 6:52 
GeneralRe: [SOS]Winsock in ATL Dll [SOS] Pin
Eytukan28-Sep-06 7:51
Eytukan28-Sep-06 7:51 
AnswerRe: [SOS]Winsock in ATL Dll [SOS] Pin
Eytukan12-Oct-06 18:24
Eytukan12-Oct-06 18:24 
QuestionATL,WTL time object in debug and release config Pin
Samy_Ibraheem_Mo26-Sep-06 7:20
Samy_Ibraheem_Mo26-Sep-06 7:20 
GeneralFunction object destructor called multiple times in std::for_each loop Pin
Rob Caldecott26-Sep-06 7:02
Rob Caldecott26-Sep-06 7:02 
GeneralA solution, of sorts Pin
Rob Caldecott26-Sep-06 7:21
Rob Caldecott26-Sep-06 7:21 
GeneralRe: Function object destructor called multiple times in std::for_each loop Pin
Zac Howland26-Sep-06 8:25
Zac Howland26-Sep-06 8:25 
GeneralRe: Function object destructor called multiple times in std::for_each loop Pin
Rob Caldecott26-Sep-06 8:30
Rob Caldecott26-Sep-06 8:30 
GeneralRe: Function object destructor called multiple times in std::for_each loop Pin
Zac Howland26-Sep-06 8:43
Zac Howland26-Sep-06 8:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.