Click here to Skip to main content
15,908,455 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Question About Serial Port in Visual C++ 2005 Pin
SimplCodr22-Jun-07 10:15
SimplCodr22-Jun-07 10:15 
QuestionPrint from buffer Pin
dellthinker22-Jun-07 8:15
dellthinker22-Jun-07 8:15 
AnswerRe: Print from buffer Pin
David Crow22-Jun-07 8:43
David Crow22-Jun-07 8:43 
GeneralRe: Print from buffer Pin
dellthinker22-Jun-07 9:07
dellthinker22-Jun-07 9:07 
GeneralRe: Print from buffer Pin
David Crow22-Jun-07 10:17
David Crow22-Jun-07 10:17 
Questionin hash tables Pin
mido++22-Jun-07 8:06
mido++22-Jun-07 8:06 
QuestionBase and derived classes Pin
ForNow22-Jun-07 6:32
ForNow22-Jun-07 6:32 
AnswerRe: Base and derived classes Pin
Mark Salsbery22-Jun-07 7:34
Mark Salsbery22-Jun-07 7:34 
In OO programming I think in terms of "is a" and "has a". "is a" means it IS a class while
"has a" refers to something that should be a member of a class.

While your method will work, it does't necessarily make sense.

To make it more clear, I'll give your classes appropriate names:

class ValidHexStringChecker;
class StringToHexConverter;

Class MyClass : public ValidHexStringChecker, public StringToHexConverter
{
};

ValidHexStringChecker and StringToHexConverter are base classes.
MyClass is a derived class, derived from both base classes.

MyClass IS A ValidHexStringChecker and it also IS A StringToHexConverter.

Unless MyClass encapsulates a string, it doesn't make sense for it to be a converter and checker.
It could HAVE ("has a") methods to do those operations but to actually BE an object that does
those doesn't make sense.

Using "is a/has a", I'd ask myself - IS Myclass a ValidHexStringChecker/StringToHexConverter?
If not, then revert to "has a", and add methods to do those operations, something like:
Class MyClass
{
public: //or protected or private
bool CheckValidHexString(...);
bool ConvertStringToHex(...);
};


ForNow wrote:
Do I have to worry about the constructers of all 3 ??


If the base classes need construction with constructors that take passed parameters, then yes.
If the base classes have default constructors, and that's the only constructor needed, then no.

ForNow wrote:
and can myClass get at the protected members of classb and CLassa


Yes, because you've specified public access to the base classes (see Controlling Access to
Class Members
[^]).

I hope at least a little of that made sense Smile | :)
Mark



"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

AnswerRe: Base and derived classes Pin
David Crow22-Jun-07 8:56
David Crow22-Jun-07 8:56 
GeneralRe: Base and derived classes Pin
ForNow22-Jun-07 12:13
ForNow22-Jun-07 12:13 
GeneralRe: Base and derived classes Pin
David Crow30-Jun-07 8:26
David Crow30-Jun-07 8:26 
GeneralRe: Base and derived classes Pin
ForNow30-Jun-07 15:47
ForNow30-Jun-07 15:47 
QuestionDoes a CListCtrl accepts a member variable name in edit mode? Pin
Arris7422-Jun-07 5:37
Arris7422-Jun-07 5:37 
AnswerRe: Does a CListCtrl accepts a member variable name in edit mode? Pin
Mark Salsbery22-Jun-07 5:44
Mark Salsbery22-Jun-07 5:44 
GeneralRe: Does a CListCtrl accepts a member variable name in edit mode? Pin
Arris7422-Jun-07 7:40
Arris7422-Jun-07 7:40 
GeneralRe: Does a CListCtrl accepts a member variable name in edit mode? Pin
Mark Salsbery22-Jun-07 8:03
Mark Salsbery22-Jun-07 8:03 
Questionhow to get Unique ID of a device Pin
VC_RYK22-Jun-07 4:52
VC_RYK22-Jun-07 4:52 
QuestionApplication Hang Pin
cpp_prgmer22-Jun-07 4:18
cpp_prgmer22-Jun-07 4:18 
QuestionRe: Application Hang Pin
David Crow22-Jun-07 4:31
David Crow22-Jun-07 4:31 
AnswerRe: Application Hang Pin
cpp_prgmer24-Jun-07 19:00
cpp_prgmer24-Jun-07 19:00 
QuestionRe: Application Hang Pin
Hamid_RT22-Jun-07 4:34
Hamid_RT22-Jun-07 4:34 
AnswerRe: Application Hang Pin
Jonathan [Darka]22-Jun-07 4:54
professionalJonathan [Darka]22-Jun-07 4:54 
GeneralRe: Application Hang Pin
cpp_prgmer24-Jun-07 19:02
cpp_prgmer24-Jun-07 19:02 
GeneralRe: Application Hang Pin
cpp_prgmer25-Jun-07 0:45
cpp_prgmer25-Jun-07 0:45 
Questionphp.h header file missing Pin
Kiran Pinjala22-Jun-07 3:50
Kiran Pinjala22-Jun-07 3:50 

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.