Click here to Skip to main content
15,891,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: function access in base and derived classes Pin
Tim Craig22-Dec-09 14:07
Tim Craig22-Dec-09 14:07 
GeneralRe: function access in base and derived classes Pin
JudyL_MD22-Dec-09 16:24
JudyL_MD22-Dec-09 16:24 
GeneralRe: function access in base and derived classes Pin
Tim Craig22-Dec-09 17:06
Tim Craig22-Dec-09 17:06 
QuestionRe: function access in base and derived classes Pin
Avi Berger22-Dec-09 18:49
Avi Berger22-Dec-09 18:49 
AnswerRe: function access in base and derived classes Pin
Tim Craig22-Dec-09 18:58
Tim Craig22-Dec-09 18:58 
GeneralRe: function access in base and derived classes [modified] Pin
Avi Berger22-Dec-09 19:21
Avi Berger22-Dec-09 19:21 
GeneralRe: function access in base and derived classes Pin
Tim Craig22-Dec-09 21:36
Tim Craig22-Dec-09 21:36 
GeneralRe: function access in base and derived classes Pin
JudyL_MD23-Dec-09 2:20
JudyL_MD23-Dec-09 2:20 
Tim Craig wrote:
But her main problem is that for whatever reason, good or bad, the derived classes shouldn't be able to see the private parts of the base class. Seems like a poor design to me but then it's not really clear why the requirement.


That requirement happens quite often for classes that deal with hardware. The base class implements the hardware interaction and the derived classes add all the validation / formatting / UI error handling / data processing on top of the hardware interaction. It's a hierarchy of adding functionality as you derive.

Think of the base class as an engine and the derived class as a car. The car must contain the functionality of the engine but it doesn't need access to the firing rate of the spark plugs and the gas flow regulator. It just needs a function that says SetOutputPower. Each different car will use the same engine.

I write lots of code that talks to hardware and usually, I don't have this problem. This situation is slightly different because of the way the interaction through the OS happens for this given piece of hardware. A solution is easy -- move those base-class members that the OS-triggered callbacks touch into module-level static variables (outside the base class) in the source file with the base class. I was seeing if there was a way to avoid this since it messes up the data encapsulation of the base class.

Judy

Be wary of strong drink. It can make you shoot at tax collectors - and miss.
Lazarus Long, "Time Enough For Love" by Robert A. Heinlein

GeneralRe: function access in base and derived classes Pin
Tim Craig23-Dec-09 9:31
Tim Craig23-Dec-09 9:31 
GeneralRe: function access in base and derived classes Pin
JudyL_MD23-Dec-09 10:08
JudyL_MD23-Dec-09 10:08 
Questionfatal error RC1015: cannot open include file 'res\Test.rc2' Pin
iwt.dev22-Dec-09 7:39
iwt.dev22-Dec-09 7:39 
AnswerRe: fatal error RC1015: cannot open include file 'res\Test.rc2' Pin
dxlee22-Dec-09 8:46
dxlee22-Dec-09 8:46 
AnswerRe: fatal error RC1015: cannot open include file 'res\Test.rc2' Pin
Abhi Lahare22-Dec-09 18:16
Abhi Lahare22-Dec-09 18:16 
Question[Message Deleted] Pin
transoft22-Dec-09 5:45
transoft22-Dec-09 5:45 
AnswerRe: .NET and COM PinPopular
Rajesh R Subramanian22-Dec-09 6:00
professionalRajesh R Subramanian22-Dec-09 6:00 
General[Message Deleted] Pin
transoft22-Dec-09 6:40
transoft22-Dec-09 6:40 
GeneralRe: .NET and COM PinPopular
Rajesh R Subramanian22-Dec-09 6:50
professionalRajesh R Subramanian22-Dec-09 6:50 
GeneralRe: .NET and COM Pin
Maximilien22-Dec-09 7:42
Maximilien22-Dec-09 7:42 
GeneralRe: .NET and COM PinPopular
Rajesh R Subramanian22-Dec-09 7:46
professionalRajesh R Subramanian22-Dec-09 7:46 
QuestionLife span of a Object???? Pin
ForNow22-Dec-09 4:29
ForNow22-Dec-09 4:29 
AnswerRe: Life span of a Object???? Pin
Maximilien22-Dec-09 4:37
Maximilien22-Dec-09 4:37 
GeneralRe: Life span of a Object???? Pin
ForNow22-Dec-09 5:44
ForNow22-Dec-09 5:44 
AnswerRe: Life span of a Object???? Pin
Rajesh R Subramanian22-Dec-09 4:45
professionalRajesh R Subramanian22-Dec-09 4:45 
GeneralRe: Life span of a Object???? Pin
LunaticFringe22-Dec-09 5:27
LunaticFringe22-Dec-09 5:27 
GeneralRe: Life span of a Object???? Pin
Rajesh R Subramanian22-Dec-09 6:02
professionalRajesh R Subramanian22-Dec-09 6:02 

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.