Click here to Skip to main content
15,905,967 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ReadDirectoryChangesW() on a network drive Pin
Joel Lucsy25-Oct-02 3:34
Joel Lucsy25-Oct-02 3:34 
GeneralRe: ReadDirectoryChangesW() on a network drive Pin
Juan Carlos SM25-Oct-02 3:45
Juan Carlos SM25-Oct-02 3:45 
QuestionHow to send a customer HTTP request to a Web Server? Pin
George225-Oct-02 3:08
George225-Oct-02 3:08 
AnswerRe: How to send a customer HTTP request to a Web Server? Pin
Todd Smith25-Oct-02 6:55
Todd Smith25-Oct-02 6:55 
Questionhow to use a bmp in a toolbar button Pin
ns25-Oct-02 2:59
ns25-Oct-02 2:59 
GeneralGeneral C++ Inheritance Question Pin
Haakon S.25-Oct-02 2:11
Haakon S.25-Oct-02 2:11 
GeneralRe: General C++ Inheritance Question Pin
Maximilien25-Oct-02 2:32
Maximilien25-Oct-02 2:32 
GeneralRe: General C++ Inheritance Question Pin
Joaquín M López Muñoz25-Oct-02 2:49
Joaquín M López Muñoz25-Oct-02 2:49 
This can be done (if I understood your question) implementing an idiom called envelope/letter. Define CAnimal as an envelope class, i.e. a class that forwards all requests to another object:
class CAnimalImpl; // more on this later
class CAnimal
{
  void method1(){impl->method1();}
  ...
  int methodn(...){return impl->methodn(...);}

  void setImpl(CAnimalImpl *impl){this->impl=impl;}
};
Now, move the definition of your dogs and cats classes to CAnimalImpl, whose signature mimics that of CAnimal:
class CAnimapImp
{
  virtual void method1()=0;
  ...
  virtual int methodn(...)=0;
};
 
class CDog: public CAnimalImp
{
  ...
};
...
Now, you have the ability to turn a dog into a cat simply by calling setImpl. Some details remain to make this robust, like for instance deciding whose responsibility it is to destroy CAnimalImpls, and define proper copy constructors.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
GeneralRe: General C++ Inheritance Question Pin
Haakon S.25-Oct-02 3:55
Haakon S.25-Oct-02 3:55 
GeneralRe: General C++ Inheritance Question Pin
Joaquín M López Muñoz25-Oct-02 4:27
Joaquín M López Muñoz25-Oct-02 4:27 
GeneralRe: General C++ Inheritance Question Pin
Maximilien25-Oct-02 4:36
Maximilien25-Oct-02 4:36 
GeneralRe: General C++ Inheritance Question Pin
Joe Woodbury25-Oct-02 6:52
professionalJoe Woodbury25-Oct-02 6:52 
GeneralMicrosoft SDK and VC++ integration question. Pin
Michael Liu25-Oct-02 2:09
Michael Liu25-Oct-02 2:09 
GeneralWindows Message Pin
Shamoon25-Oct-02 2:03
Shamoon25-Oct-02 2:03 
GeneralRe: Windows Message Pin
Maximilien25-Oct-02 2:33
Maximilien25-Oct-02 2:33 
GeneralRe: Windows Message Pin
Paul M Watt25-Oct-02 5:04
mentorPaul M Watt25-Oct-02 5:04 
GeneralRe: Windows Message Pin
pba_25-Oct-02 11:46
pba_25-Oct-02 11:46 
GeneralFont Calculation for a String . Pin
Muhammad Kamran25-Oct-02 1:40
Muhammad Kamran25-Oct-02 1:40 
GeneralRe: Font Calculation for a String . Pin
Daniel Turini25-Oct-02 2:24
Daniel Turini25-Oct-02 2:24 
GeneralRe: Font Calculation for a String . Pin
Muhammad Kamran25-Oct-02 2:39
Muhammad Kamran25-Oct-02 2:39 
GeneralRe: Font Calculation for a String . Pin
dabs25-Oct-02 3:40
dabs25-Oct-02 3:40 
General_tfullpath(..) for http:// paths Pin
Anonymous25-Oct-02 1:12
Anonymous25-Oct-02 1:12 
GeneralRe: _tfullpath(..) for http:// paths Pin
Anonymous25-Oct-02 2:15
Anonymous25-Oct-02 2:15 
QuestionFront Page Automation is worthy ? Pin
Braulio Dez25-Oct-02 0:00
Braulio Dez25-Oct-02 0:00 
AnswerRe: Front Page Automation is worthy ? Pin
Anonymous25-Oct-02 1:43
Anonymous25-Oct-02 1: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.