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

C / C++ / MFC

 
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 
Hi,

I am creating a framework for an acquisition of (sampled) data, e.g. images at a certain 'sampling' (every 2sec for ex.).
I'd like to use some interfaces to create a kinda 'generic' framework in C++ (therefore by using pure abstract classes):

First, each sample data has basic functionalities, described in an interface:

class ISampleData
{
public:
virtual bool Load(const char* lpszFilenameIn) = 0;
virtual bool Save(const char* lpszFilenameOut) = 0;
...
};

Second, a 'generic' interface for an acquisition digitizer describes basic features:

class IInputDigitizer
{
public:
virtual ISampleData& Acquire() = 0;
...
};

Then, I'd like to create an implementation of these interfaces in the case of image acquisition:

class CImage : public ISampleData
{
public:
CImage();
virtual ~CImage();

virtual bool Load(const char* lpszFilenameIn);
virtual bool Save(const char* lpszFilenameOut);
...
};

class CCameraDigitizer : public IInputDigitizer
{
public:
CCameraDigitizer();
virtual ~CCameraDigitizer();

virtual CImage& Acquire();
...
};

Some problems occur when I try something like this in the main prog:

m_lpDigitizer = new CCameraDigitizer();
CImage image = m_lpDigitizer->Acquire();

with, of course, the error
error C2440: 'initializing' : cannot convert from 'ISampleData' to 'CImage'

I m not sure I understand the problem Unsure | :~ (reverse polymorhism? pb with abstract class instantiation?)

What can be a cure? a solution? without loosing this kind of design "Generic to Specialized using the elegance of interfaces".

Smile | :)

Thanks a lot,

Bertrand

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 
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 

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.