Why don't you use a dummy argument in the second speak function i.e. to overload it like it is used for pre/post increment/decrement operators void speak(char *str); //For cat object void speak(char *str, int dummy);//For dog object Really speaking an elegant solution is as Christian suggested using inheritance / virtual functions... :cool: --------------------------- Atul
Atul Dharne
Posts
-
Beginner looking for help -
Do you still read comics?I love C & H and TinTin..It still seems fresh and humorous...:) During ur youth these are part of ur daily life u cannot detach even after so many years.. #ifndef YOUTH #define YOUTH everlasting #endif
-
Funny comments....LOL so now are you alone ;P
-
Funny comments....LOL so now are you alone ;P
-
Some good code...www.funducode.com Fundu for us indians means cool... a good site, a resp author(guru) but short variable names... yadda cadda madda a good decision to keep site read only to genuine half twits :eek:
-
const OR NOT constIMHO the compiler smartly makes an optimization that if your variable is not a l-value then there is no need to read once it has been read at start. So maybe if an register is free this value goes in there and there are no further reads to that variable throuhout the program. This optimization can be disable by preceding any variable with the keyword 'volatile' which turns off this optimization. So const keyword makes clear to the compiler that this variable cannot be a l-value. Using const with member functions is just a checkpoint that none of the member variables are being changed and if some coder tries changing other coder's code by assigning some values to member vars it will be flagged of as an error keeping the orig coder's intentions intact...