Click here to Skip to main content
16,019,740 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help me about DICOM file Pin
thangnvhl24-Feb-05 22:51
thangnvhl24-Feb-05 22:51 
GeneralRe: Help me about DICOM file Pin
Ravi Bhavnani25-Feb-05 3:47
professionalRavi Bhavnani25-Feb-05 3:47 
GeneralSpell Checker - Urgent Pin
rjnl24-Feb-05 15:47
rjnl24-Feb-05 15:47 
GeneralRe: Spell Checker - Urgent Pin
Christian Graus24-Feb-05 16:31
protectorChristian Graus24-Feb-05 16:31 
GeneralRe: Spell Checker - Urgent Pin
PJ Arends24-Feb-05 17:16
professionalPJ Arends24-Feb-05 17:16 
GeneralConvert 3gp to mpeg1 Pin
Member 448120724-Feb-05 14:34
Member 448120724-Feb-05 14:34 
Questionhow to alter the CScrollBar control color Pin
kcynic24-Feb-05 14:00
kcynic24-Feb-05 14:00 
Generalmuliple-inheriting two functions with identical signatures Pin
moredip24-Feb-05 13:17
moredip24-Feb-05 13:17 
Hi all,

I was hoping for some advice regarding multiple inheritance. In my application I have two interfaces (abstract classes), ICamera and IOrientation. I also have a class C3DCamera, which inherits from both interfaces:

public class ICamera
{
public:
  virtual ~ICamera()
  {}

  virtual ICamera *CreateClone() const = 0;
  
  //...
  //rest of ICamera's interface
};

public class IOrientation
{
public:
  virtual ~IOrientation()
  {}

  //...
  //rest of IOrientation's interface
};

public class C3DCamera : public ICamera, public IOrientation
{

  //ICamera implementation
  ICamera *CreateClone() const;

  //...
  //rest of C3DCamera's declaration
}


Now, I need to modify IOrientation's interface by adding a IOrientation *CreateClone() const method, but of course I can't because C3DCamera can't have two methods with the same signature. I was hoping I could dis-ambiguate between the two like you can with interface method implementations in C#, but it seems you can't (right?).

So what I'm looking for is some advice on what the best way to proceed is. I need both interfaces to expose some form of CreateClone() functionality, so that clients can create local copies of classes that implement those interface.

Here are the options I see:


  1. simply rename the interfaces' methods to CreateICameraClone(), CreateIOrientationClone, etc.
  2. Use the technique I read about in Item 43 of Effective C++ - create CCamera and COrientation classes that declare pure virtual CreateICameraClone()/CreateIOrientationClone() methods and define a n overrideable default implementation of CreateClone which calls the appropriate pure virtual method
  3. ????


Option 1 would be the simplest, but seems a little messy to me. Option 2 is the 'recommended approach', I guess, but seems a little forced.

Anyone have any other options, or advice in general?

TIA,

Pete
GeneralRe: muliple-inheriting two functions with identical signatures Pin
PJ Arends24-Feb-05 15:34
professionalPJ Arends24-Feb-05 15:34 
GeneralRe: muliple-inheriting two functions with identical signatures Pin
moredip25-Feb-05 5:43
moredip25-Feb-05 5:43 
GeneralRe: muliple-inheriting two functions with identical signatures Pin
Ryan Binns24-Feb-05 17:50
Ryan Binns24-Feb-05 17:50 
GeneralRe: muliple-inheriting two functions with identical signatures Pin
moredip25-Feb-05 6:00
moredip25-Feb-05 6:00 
GeneralRe: muliple-inheriting two functions with identical signatures Pin
Ryan Binns26-Feb-05 19:10
Ryan Binns26-Feb-05 19:10 
GeneralRe: muliple-inheriting two functions with identical signatures Pin
moredip1-Mar-05 5:46
moredip1-Mar-05 5:46 
GeneralRe: muliple-inheriting two functions with identical signatures Pin
Ravi Bhavnani25-Feb-05 3:55
professionalRavi Bhavnani25-Feb-05 3:55 
GeneralRe: muliple-inheriting two functions with identical signatures Pin
moredip25-Feb-05 5:57
moredip25-Feb-05 5:57 
GeneralRe: muliple-inheriting two functions with identical signatures Pin
cmk25-Feb-05 11:40
cmk25-Feb-05 11:40 
GeneralRe: muliple-inheriting two functions with identical signatures Pin
moredip25-Feb-05 12:04
moredip25-Feb-05 12:04 
GeneralRe: muliple-inheriting two functions with identical signatures Pin
cmk25-Feb-05 16:12
cmk25-Feb-05 16:12 
GeneralRe: muliple-inheriting two functions with identical signatures Pin
moredip1-Mar-05 5:41
moredip1-Mar-05 5:41 
GeneralUSB Port Pin
Member 47204524-Feb-05 11:11
Member 47204524-Feb-05 11:11 
GeneralRe: USB Port Pin
namaskaaram24-Feb-05 21:34
namaskaaram24-Feb-05 21:34 
GeneralAssigning Member Variables to Controls Pin
Veronique72224-Feb-05 10:04
Veronique72224-Feb-05 10:04 
GeneralRe: Assigning Member Variables to Controls Pin
David Crow24-Feb-05 10:31
David Crow24-Feb-05 10:31 
GeneralRe: Assigning Member Variables to Controls Pin
Veronique72224-Feb-05 10:39
Veronique72224-Feb-05 10:39 

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.