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

C / C++ / MFC

 
GeneralRe: Overloading methods with identical content in lot of derived classes Pin
CPallini8-Jul-16 9:00
mveCPallini8-Jul-16 9:00 
GeneralRe: Overloading methods with identical content in lot of derived classes Pin
FriendOfAsherah10-Jul-16 20:16
FriendOfAsherah10-Jul-16 20:16 
GeneralRe: Overloading methods with identical content in lot of derived classes Pin
ellegonzalez18-Aug-16 22:59
ellegonzalez18-Aug-16 22:59 
GeneralRe: Overloading methods with identical content in lot of derived classes Pin
leon de boer8-Jul-16 3:01
leon de boer8-Jul-16 3:01 
GeneralRe: Overloading methods with identical content in lot of derived classes Pin
FriendOfAsherah8-Jul-16 3:47
FriendOfAsherah8-Jul-16 3:47 
GeneralRe: Overloading methods with identical content in lot of derived classes Pin
leon de boer8-Jul-16 18:25
leon de boer8-Jul-16 18:25 
GeneralRe: Overloading methods with identical content in lot of derived classes Pin
FriendOfAsherah10-Jul-16 20:32
FriendOfAsherah10-Jul-16 20:32 
AnswerRe: Overloading methods with identical content in lot of derived classes Pin
FriendOfAsherah13-Jul-16 0:45
FriendOfAsherah13-Jul-16 0:45 
an example:
We have animals, cats and dogs

C++
class animal()
{
   OpenMouth() ;
   breath_in();
   breath_out();
}
class cat() : public animal
{ 
   play_with_wool();
}
class dog() : public animal
{
   hunt_cats();
}
class mops1() : public dog
{ 
   get_fat_and_fart()
}
class mops2() : public dog
{ 
   get_fat()
}
class greyhound1() : public dog 
{
  run()
}
class specialdog() : public dog
{
  run_fast()
}


now we want to extent _some_ dogs to know how to barf()
for barf() we need some unctions of animal() (not all)

C++
barf() { breath_in(); OpenMouth(); dosomething(); }


How can we add barf() to some (eg. 20 different dogs, and also some wolfs) without changing parent class structure?

class greyhound1() : public dog 
{
  run()
  barf(); // added ... 
}
class specialdog() : public dog
{
  run_fast()
  barf(); // added ... 
}
class greywolf() : public wolf
{ 
   barf(); // added
} 


and next step: we have not only barf() we have 20 new extends for these aimals.
It would mean: add these 20 functions to each animal seperately?
AnswerRe: Overloading methods with identical content in lot of derived classes Pin
Krishnakumartg19-Jul-16 20:14
Krishnakumartg19-Jul-16 20:14 
GeneralRe: Overloading methods with identical content in lot of derived classes Pin
FriendOfAsherah19-Jul-16 23:06
FriendOfAsherah19-Jul-16 23:06 
QuestionCMFCRibbonBar High DPI Pin
Paul Harrison 26-Jul-16 7:12
Paul Harrison 26-Jul-16 7:12 
QuestionInternet Explorer Pin
Member 125311295-Jul-16 2:58
Member 125311295-Jul-16 2:58 
AnswerRe: Internet Explorer Pin
Chris Losinger5-Jul-16 5:12
professionalChris Losinger5-Jul-16 5:12 
GeneralRe: Internet Explorer Pin
Member 125311295-Jul-16 20:16
Member 125311295-Jul-16 20:16 
QuestionSuport for MFC Pin
Bram van Kampen3-Jul-16 14:15
Bram van Kampen3-Jul-16 14:15 
AnswerRe: Suport for MFC Pin
Daniel Pfeffer3-Jul-16 20:50
professionalDaniel Pfeffer3-Jul-16 20:50 
GeneralRe: Suport for MFC Pin
Bram van Kampen4-Jul-16 14:19
Bram van Kampen4-Jul-16 14:19 
AnswerRe: Suport for MFC Pin
Jochen Arndt3-Jul-16 21:12
professionalJochen Arndt3-Jul-16 21:12 
GeneralRe: Suport for MFC Pin
Bram van Kampen4-Jul-16 13:59
Bram van Kampen4-Jul-16 13:59 
GeneralRe: Suport for MFC Pin
Jochen Arndt4-Jul-16 21:34
professionalJochen Arndt4-Jul-16 21:34 
AnswerRe: Suport for MFC Pin
leon de boer4-Jul-16 20:55
leon de boer4-Jul-16 20:55 
GeneralRe: Suport for MFC Pin
Bram van Kampen10-Jul-16 16:49
Bram van Kampen10-Jul-16 16:49 
QuestionHow to handle runtime access violation exception Pin
Django_Untaken3-Jul-16 11:18
Django_Untaken3-Jul-16 11:18 
AnswerRe: How to handle runtime access violation exception Pin
Bram van Kampen3-Jul-16 14:32
Bram van Kampen3-Jul-16 14:32 
AnswerRe: How to handle runtime access violation exception Pin
Jochen Arndt3-Jul-16 21:29
professionalJochen Arndt3-Jul-16 21:29 

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.