Click here to Skip to main content
15,912,329 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Access specifier in multiple inheritance Pin
«_Superman_»30-Sep-13 19:05
professional«_Superman_»30-Sep-13 19:05 
You cannot really change the access type in a derived class.
Consider the situation where Derived derives from Base in your example - class Derived : public Base

In this case, if you create an object of Base, then Identity() would be public.
And if you create an object of Derived, then Identity() would be protected.
This is probably what you want, but this behavior is only because when the Base object is created, the compiler sees Identity() as public and when the Derived object is created the compiler see Identity() as protected.

But if you do this - Base* ptr = new Derived;
And access Identity() like this - ptr->Identity();
You will be able to do this, since Identity() is still public and not changed to protected.

So even though, you're creating an object of Derived, the compiler only checks the class Base since the pointer is of type Base.
«_Superman 
I love work. It gives me something to do between weekends.


Microsoft MVP (Visual C++) (October 2009 - September 2013)

Polymorphism in C

QuestionRe: Access specifier in multiple inheritance Pin
TheHelenLee30-Sep-13 19:25
TheHelenLee30-Sep-13 19:25 
AnswerRe: Access specifier in multiple inheritance Pin
pasztorpisti30-Sep-13 23:11
pasztorpisti30-Sep-13 23:11 
QuestionAdodc : how to retrieve single value into EditBox Pin
coolerfantasy29-Sep-13 21:02
coolerfantasy29-Sep-13 21:02 
QuestionRe: Adodc : how to retrieve single value into EditBox Pin
David Crow30-Sep-13 3:07
David Crow30-Sep-13 3:07 
AnswerRe: Adodc : how to retrieve single value into EditBox Pin
coolerfantasy30-Sep-13 19:42
coolerfantasy30-Sep-13 19:42 
GeneralRe: Adodc : how to retrieve single value into EditBox Pin
Freak301-Oct-13 0:46
Freak301-Oct-13 0:46 
GeneralRe: Adodc : how to retrieve single value into EditBox Pin
coolerfantasy1-Oct-13 20:05
coolerfantasy1-Oct-13 20:05 
GeneralRe: Adodc : how to retrieve single value into EditBox Pin
Freak302-Oct-13 1:50
Freak302-Oct-13 1:50 
GeneralRe: Adodc : how to retrieve single value into EditBox Pin
coolerfantasy2-Oct-13 20:01
coolerfantasy2-Oct-13 20:01 
GeneralRe: Adodc : how to retrieve single value into EditBox Pin
David Crow3-Oct-13 5:56
David Crow3-Oct-13 5:56 
GeneralRe: Adodc : how to retrieve single value into EditBox Pin
coolerfantasy5-Oct-13 19:46
coolerfantasy5-Oct-13 19:46 
Questionhow to configure googletest for "test code covearge" in visual studio 2010 [modified] Pin
pk jain29-Sep-13 19:35
pk jain29-Sep-13 19:35 
AnswerRe: how to configure googletest for "test code covearge" in visual studio 2010 [modified] Pin
Richard MacCutchan29-Sep-13 20:53
mveRichard MacCutchan29-Sep-13 20:53 
QuestionMonitoring application memory usage Pin
dushkin29-Sep-13 7:33
dushkin29-Sep-13 7:33 
SuggestionRe: Monitoring application memory usage Pin
David Crow29-Sep-13 16:40
David Crow29-Sep-13 16:40 
GeneralRe: Monitoring application memory usage Pin
dushkin29-Sep-13 20:12
dushkin29-Sep-13 20:12 
GeneralRe: Monitoring application memory usage Pin
David Crow30-Sep-13 3:06
David Crow30-Sep-13 3:06 
GeneralRe: Monitoring application memory usage Pin
jschell30-Sep-13 8:30
jschell30-Sep-13 8:30 
AnswerRe: Monitoring application memory usage Pin
ExcellentOrg29-Sep-13 23:48
ExcellentOrg29-Sep-13 23:48 
AnswerRe: Monitoring application memory usage Pin
Rolf Kristensen30-Sep-13 22:57
Rolf Kristensen30-Sep-13 22:57 
QuestionCSplitterWnd not showing Pin
Richard Andrew x6428-Sep-13 18:52
professionalRichard Andrew x6428-Sep-13 18:52 
SuggestionRe: CSplitterWnd not showing Pin
Richard MacCutchan28-Sep-13 21:24
mveRichard MacCutchan28-Sep-13 21:24 
AnswerRe: CSplitterWnd not showing Pin
«_Superman_»28-Sep-13 21:58
professional«_Superman_»28-Sep-13 21:58 
QuestionRe: CSplitterWnd not showing Pin
Richard Andrew x6429-Sep-13 5:10
professionalRichard Andrew x6429-Sep-13 5:10 

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.