Click here to Skip to main content
15,923,789 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Tomasz Sowinski7-Oct-02 2:18
Tomasz Sowinski7-Oct-02 2:18 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Bertrand Boichon7-Oct-02 10:20
Bertrand Boichon7-Oct-02 10:20 
Here is the Acquire function, using a reference to a CImage (derived from ISampleData pure abstract class):

ISampleData& CCameraDigitizer::Acquire()
{
CImage sample;
// ... perform actual acquisition here ...
return sample;
}

The question is: what should I return ISampleData& (object by ref) or ISampleData* (pointer to obj, by value)?

I did some more tests on that matter (because I realized I don't know much about passing by reference vs by value). I added a dynamically allocated (on the heap) buffer (for the image itself) and an 'int' data field in the CImage class. Then I tried to use these in methods like Save or Display:

CImage image = (CImage&) m_lpDigitizer->Acquire();
image.Save("TEST.JPG");
image.Display();

I came to realize that even if Save and Display (using the buffer data field) are called correctly (what I saw at first), it actually displays crap since the buffer is pointing a random location, along with the 'int' field.

So the only solution is to return a pointer to a CImage obj (therefore allocated on the heap):

ISampleData* CCameraDigitizer::Acquire()
{
CImage* pSample = new CImage();
// ... perform actual acquisition here ...
return pSample;
}

And it works.

What do you think?

Best regards,
Bertrand Boichon

GeneralRe: Inheritance, interfaces and polymorphism... Pin
Tomasz Sowinski7-Oct-02 11:19
Tomasz Sowinski7-Oct-02 11:19 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Bertrand Boichon7-Oct-02 11:23
Bertrand Boichon7-Oct-02 11:23 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Tomasz Sowinski8-Oct-02 4:26
Tomasz Sowinski8-Oct-02 4:26 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Bertrand Boichon8-Oct-02 8:19
Bertrand Boichon8-Oct-02 8:19 
GeneralToolbar button state (enable/disable) Pin
Daniel Strigl3-Oct-02 22:40
Daniel Strigl3-Oct-02 22:40 
GeneralRe: Toolbar button state (enable/disable) Pin
Tomasz Sowinski4-Oct-02 0:05
Tomasz Sowinski4-Oct-02 0:05 
GeneralProblem with CMultiRectTracker into CScrollView Pin
Gianfranco3-Oct-02 22:39
Gianfranco3-Oct-02 22:39 
GeneralRe: Problem with CMultiRectTracker into CScrollView Pin
Tomasz Sowinski4-Oct-02 0:16
Tomasz Sowinski4-Oct-02 0:16 
GeneralIHTMLSelectionObject Pin
candan3-Oct-02 22:27
professionalcandan3-Oct-02 22:27 
GeneralRe: IHTMLSelectionObject Pin
Stephane Rodriguez.3-Oct-02 23:25
Stephane Rodriguez.3-Oct-02 23:25 
GeneralRe: IHTMLSelectionObject Pin
candan7-Oct-02 15:17
professionalcandan7-Oct-02 15:17 
GeneralRe: IHTMLSelectionObject Pin
Stephane Rodriguez.7-Oct-02 19:10
Stephane Rodriguez.7-Oct-02 19:10 
GeneralRe: IHTMLSelectionObject Pin
candan7-Oct-02 19:17
professionalcandan7-Oct-02 19:17 
QuestionHow can I change the bitmap of a toolbar button at runtime? Pin
Daniel Strigl3-Oct-02 22:17
Daniel Strigl3-Oct-02 22:17 
AnswerRe: How can I change the bitmap of a toolbar button at runtime? Pin
Anonymous3-Oct-02 22:37
Anonymous3-Oct-02 22:37 
AnswerRe: How can I change the bitmap of a toolbar button at runtime? Pin
Tomasz Sowinski4-Oct-02 0:44
Tomasz Sowinski4-Oct-02 0:44 
GeneralRe: How can I change the bitmap of a toolbar button at runtime? Pin
Daniel Strigl4-Oct-02 2:44
Daniel Strigl4-Oct-02 2:44 

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.