Click here to Skip to main content
15,898,134 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: HWND list Pin
Daniel Ferguson4-Oct-02 6:22
Daniel Ferguson4-Oct-02 6:22 
GeneralThanks Pin
The_Server4-Oct-02 14:27
The_Server4-Oct-02 14:27 
GeneralVisual c++ and continue statement Pin
Sas284-Oct-02 1:14
Sas284-Oct-02 1:14 
GeneralRe: Visual c++ and continue statement Pin
Jon Hulatt4-Oct-02 1:14
Jon Hulatt4-Oct-02 1:14 
GeneralRe: Visual c++ and continue statement Pin
jmkhael4-Oct-02 2:57
jmkhael4-Oct-02 2:57 
GeneralRe: Visual c++ and continue statement Pin
Daniel Turini4-Oct-02 5:01
Daniel Turini4-Oct-02 5:01 
GeneralRe: Visual c++ and continue statement Pin
Joe Woodbury7-Oct-02 21:30
professionalJoe Woodbury7-Oct-02 21:30 
GeneralStill inheritance... Pin
Bertrand Boichon3-Oct-02 23:32
Bertrand Boichon3-Oct-02 23:32 
GeneralRe: Still inheritance... Pin
Tomasz Sowinski4-Oct-02 0:01
Tomasz Sowinski4-Oct-02 0:01 
GeneralRe: Still inheritance... Pin
Ranjan Banerji4-Oct-02 3:21
Ranjan Banerji4-Oct-02 3:21 
GeneralRe: Still inheritance... Pin
Tomasz Sowinski4-Oct-02 3:30
Tomasz Sowinski4-Oct-02 3:30 
GeneralRe: Still inheritance... Pin
Ranjan Banerji4-Oct-02 5:09
Ranjan Banerji4-Oct-02 5:09 
GeneralRe: Still inheritance... Pin
Tomasz Sowinski4-Oct-02 5:26
Tomasz Sowinski4-Oct-02 5:26 
GeneralRe: Still inheritance... Pin
Ranjan Banerji4-Oct-02 5:34
Ranjan Banerji4-Oct-02 5:34 
GeneralRe: Still inheritance... Pin
Tomasz Sowinski4-Oct-02 5:44
Tomasz Sowinski4-Oct-02 5:44 
GeneralRe: Still inheritance... Pin
Ranjan Banerji4-Oct-02 5:47
Ranjan Banerji4-Oct-02 5:47 
GeneralRe: Still inheritance... Pin
Tomasz Sowinski4-Oct-02 5:55
Tomasz Sowinski4-Oct-02 5:55 
GeneralRe: Still inheritance... Pin
Ranjan Banerji4-Oct-02 5:58
Ranjan Banerji4-Oct-02 5:58 
GeneralRe: Still inheritance... Pin
Tomasz Sowinski4-Oct-02 6:13
Tomasz Sowinski4-Oct-02 6:13 
GeneralRe: Still inheritance... Pin
Ranjan Banerji4-Oct-02 6:35
Ranjan Banerji4-Oct-02 6:35 
GeneralInheritance, interfaces and polymorphism... Pin
Bertrand Boichon3-Oct-02 22:57
Bertrand Boichon3-Oct-02 22:57 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Tomasz Sowinski3-Oct-02 23:56
Tomasz Sowinski3-Oct-02 23:56 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Bertrand Boichon4-Oct-02 13:59
Bertrand Boichon4-Oct-02 13:59 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Tomasz Sowinski5-Oct-02 0:35
Tomasz Sowinski5-Oct-02 0:35 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Bertrand Boichon5-Oct-02 14:00
Bertrand Boichon5-Oct-02 14:00 
Ok... more questions: Big Grin | :-D

First of all, what do you mean CImage& is cheating? I mean, to me, it seems logical to use the reference (address in memory) of a CImage object (base on ISampleData interface), since I cannot return an instance (by value) of type ISampleData (pure abstract class).

Secondly, what do you mean by "inefficient"? Passing/returning by value versus by reference?
The other possiblity is to create the object on the heap (with new) and pass/return the pointer by value, like this:

ISampleData* Acquire()
{
CImage* result = new CImage();
...
return result;
}

CImage* image = (CImage*) Acquire();

But then I thought doing that is less "efficient" than copying an object to the 'caller' stack (by returning a reference to a CImage obj)????


The other thing is:
Surprisingly (and I thought the same as you did) polymorphism is NOT lost, and I don't know why...
I made a little experiment: I created a method in my class CImage called Display() which is not overloaded from CSampleData (i.e. just a new method specific to CImage). Then I did exactly as before (with "Acquire()" returning a reference to ISampleData):

CImage image = (CImage&) m_lpDigitizer->Acquire();

And guess what? when I call "image.Display()", well it works fine!

Why? Is it because I am dealing with reference to an object, not the object itself. Polymorphism apply to an object copy (by value), not to a reference copy of it?


Bertrand Boichon









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.