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

C / C++ / MFC

 
GeneralRe: Calling mfc dll from visual basic Pin
randynamics2-Oct-04 21:17
randynamics2-Oct-04 21:17 
GeneralRe: Calling mfc dll from visual basic Pin
Gary R. Wheeler2-Oct-04 12:49
Gary R. Wheeler2-Oct-04 12:49 
GeneralRe: Calling mfc dll from visual basic Pin
randynamics3-Oct-04 18:25
randynamics3-Oct-04 18:25 
GeneralUsing btimap resource from dll Pin
bigmirror1-Oct-04 14:28
bigmirror1-Oct-04 14:28 
GeneralRe: Using btimap resource from dll Pin
Andrzej Markowski1-Oct-04 16:43
Andrzej Markowski1-Oct-04 16:43 
GeneralProblem with FindWindow Pin
Dev5781-Oct-04 14:25
Dev5781-Oct-04 14:25 
GeneralRe: Problem with FindWindow Pin
Jörgen Sigvardsson1-Oct-04 14:36
Jörgen Sigvardsson1-Oct-04 14:36 
Generalprotected constructor Pin
leonid dmsi1-Oct-04 12:23
leonid dmsi1-Oct-04 12:23 
Hello,

I have following C++ class hiererarchy like this:

class CBase{
protected:
// Construction/Destraction
CBase(){};
CBase(const CBase& Src){}; // Copy constractor
virtual ~CBase(){};
// Operators
virtual const CBase& operator =(const CBase& Src){}; // = operator
};

class CDerived: public CBase{
public:
// Construction/Destraction
CDerived(){};
CDerived(const CDerived& Src); // Copy constractor
virtual ~CDerived(){};
// Operators
virtual const CDerived& operator =(const CDerived& Src); // = operator
};

CDerived::CDerived(const CDerived& Src):CBase((CBase) Src)
{
//Do something here....
}

const CDerived& CDerived::operator =(const CDerived& Src)
{
if(&Src == this)
return *this;
(Base) *this = (Base) Src;
// Do something here ...
return *this;
}

Visual C++.NET compiler generates errors:
error C2248: CBase::CBase' : cannot access protected member declared in class 'CBase'.

Obviously if I changed 'CBase' as following:
class CBase{
public:
// Construction/Destraction
CBase(){};
CBase(const CBase& Src){}; // Copy constractor
virtual ~CBase(){};
// Operators
virtual const CBase& operator =(const CBase& Src){}; // = operator
};

program would compile without problems. But I need keep 'CBase' construction protected to allow instantiation of 'CBase' only via derived classes.

Does anyone have an idea how this can be fixed? Any help will be greatly appreciated.

Thanks,

Leonid
GeneralRe: protected constructor Pin
alex.barylski1-Oct-04 16:12
alex.barylski1-Oct-04 16:12 
Generaltypedef for Function Pointer Pin
act_x1-Oct-04 10:59
act_x1-Oct-04 10:59 
GeneralRe: typedef for Function Pointer Pin
Gary R. Wheeler1-Oct-04 12:39
Gary R. Wheeler1-Oct-04 12:39 
GeneralRe: typedef for Function Pointer Pin
Jörgen Sigvardsson1-Oct-04 12:50
Jörgen Sigvardsson1-Oct-04 12:50 
GeneralRe: typedef for Function Pointer Pin
Michael Dunn1-Oct-04 14:03
sitebuilderMichael Dunn1-Oct-04 14:03 
GeneralRe: typedef for Function Pointer Pin
Gary R. Wheeler2-Oct-04 2:00
Gary R. Wheeler2-Oct-04 2:00 
GeneralDLL problem Pin
Larsson1-Oct-04 10:36
Larsson1-Oct-04 10:36 
GeneralRe: DLL problem Pin
ThatsAlok1-Oct-04 18:30
ThatsAlok1-Oct-04 18:30 
GeneralRe: DLL problem Pin
Larsson1-Oct-04 22:16
Larsson1-Oct-04 22:16 
General#define style templates and float Pin
J.B.1-Oct-04 9:15
J.B.1-Oct-04 9:15 
GeneralRe: #define style templates and float Pin
David Crow1-Oct-04 9:35
David Crow1-Oct-04 9:35 
GeneralRe: #define style templates and float Pin
vcplusplus1-Oct-04 10:26
vcplusplus1-Oct-04 10:26 
GeneralRe: #define style templates and float Pin
J.B.1-Oct-04 19:46
J.B.1-Oct-04 19:46 
QuestionHow slow is GDI? Pin
Budric B.1-Oct-04 6:13
Budric B.1-Oct-04 6:13 
AnswerRe: How slow is GDI? Pin
Nathan Holt at EMOM1-Oct-04 6:29
Nathan Holt at EMOM1-Oct-04 6:29 
GeneralRe: That did it! Pin
Budric B.1-Oct-04 6:48
Budric B.1-Oct-04 6:48 
GeneralRe: Movie playing software Pin
Nathan Holt at EMOM1-Oct-04 7:05
Nathan Holt at EMOM1-Oct-04 7:05 

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.