You are so right,the screwy code would help greatestCommonDenominator() { int gcd, same, hold1, hold2; if(iNumerator < iDenominator){ for(gcd=1;gcd
Jason K Dove
Posts
-
Beginner's Question II -
Beginner's QuestionI can't for the life of me figure out the simplest of problems. I am trying to capture the greatest common denominator of two integers and can't seem to get more than garbage for the output. Any algorithmic nudge in the right direction would be most appreciated.
-
Beginner looking for helpI got it. Thank you for all your help.;) It help to have perspective Dove #include #include "Cat.h" #include "Dog.h" void speak(CCat c); void speak(CDog d); void main() { CCat cat1; CDog dog1; cat1.catname = "Felix"; dog1.dogname = "Fido"; speak(cat1); speak(dog1); } void speak(CCat c) { cout << c.catname << " says meow " << endl; } void speak(CDog d) { cout << d.dogname << " says woof " << endl; }
-
Beginner looking for helpthank you so much for the swift reply, I'm glad I'm not the only one up browsing the boards. I agree with all the points you made, and it certainly is quite easier to handle with separate, 1 class called functions. Unfortunately for me, the book I'm using seems to think it is a simple exercise, and the parameters are quiet clear. I must perform it as I posted it to the board. I played with the pointer to the memory location, like you first suggested, though only briefly. I will go back and try it again. The one question that keeps popping into my mind isn't how to overload the functions. It is how to pass the different arguments. If I can figure out how to differentiate which class object I am passing, then it can work. *deep, deeeeeep sigh* Much Appreciatively, Jason K. Dove
-
Beginner looking for helpProblem seems simple, hours later and no documentation, I see I am licked. I am doing an exercise with a Win32 Console app, and I am attempting to write 2 overload functions to pass 2 similiar class objects to the function and recieve different results based on what I am passing. The parameters of the exercise are quite clear and as I have written thus far. Certainly there are better ways to code the end result, but I am not in control of the requirements. :( I am passing 2 char class objects and trying to get it to do 2 different things. What I can figure out is how to beat ambiguity. What do I have to pass it in order make this work. Any help for the idiot league of programming would be appreciateed. My code so far, notes attached Using Visual C++ compiler #ifndef _CLASSCAT121212121212112_ // 2 classes declared a cat and a dog #define _CLASSCAT121212121212112_ class CCat { public: char* catname; }; #endif #ifndef _CLASSDOG5456454654656546_ #define _CLASSDOG5456454654656546_ class CDog { public: char* dogname; }; #endif #include #include "Cat.h" #include "Dog.h" void speak(char* n); void speak(char* &n); void main() { CCat cat1; CDog dog1; cat1.catname = "Felix"; dog1.dogname = "Fido"; speak("Felix"); speak(); <--- // how do I pass the dog argument to the function? How do I differentiate the two } void speak(char* n) { cout << n << " says meow " << endl; } void speak() // must make the dog go woof, but how do I pass it a different argument? // how do I overload to beat ambiguity { cout << d << " says woof " << endl; } Much Thanks, Jason K. Dove