Help please, getting this to compile (using Dev C++)

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2004
Posts: 48
Reputation: Coach_Nate is an unknown quantity at this point 
Solved Threads: 0
Coach_Nate's Avatar
Coach_Nate Coach_Nate is offline Offline
Light Poster

Help please, getting this to compile (using Dev C++)

 
0
  #1
Sep 10th, 2005
Trying to get this to compile is driving me nuts! Any help is greatly appreciated. I think it's having trouble linking the header to the .cpp files. It's my first program in Dev C++ - I'm used to using Visual Studio.

Here's the source for the header header:
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include "SmpMth.h"
  4. using namespace std;
  5.  
  6. int SmpMth::Add(int a, int b)
  7. //Postcondition:
  8. // The sum of two ints is returned
  9. {
  10. return a+b;
  11. }
  12.  
  13. int SmpMth::Max(int a, int b)
  14. //Postcondition:
  15. // The maximum of two ints is returned
  16. {
  17. if(a>b)
  18. {
  19. return a;
  20. }
  21. else
  22. return b;
  23. }
  24.  
  25. int SmpMth::Min(int a, int b)
  26. //Postcondition:
  27. // The minimum of two ints is returned
  28. {
  29. if(a<b)
  30. return a;
  31. else
  32. return b;
  33. }

and here's the header:
  1. #include <iostream>
  2. #include <stdlib.h>
  3. using namespace std;
  4.  
  5. class SmpMth
  6. {
  7. public:
  8. int Add(int, int);
  9. int Max(int, int);
  10. int Min(int, int);
  11. SmpMth();
  12. SmpMth(int, int);
  13. private:
  14.  
  15. };

Thanks in advance for any help,
Nate
Behind every great gymnast - is a mentally unstable coach.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 48
Reputation: Coach_Nate is an unknown quantity at this point 
Solved Threads: 0
Coach_Nate's Avatar
Coach_Nate Coach_Nate is offline Offline
Light Poster

Re: Help please, getting this to compile (using Dev C++)

 
0
  #2
Sep 10th, 2005
Sorry, I forgot to say what the error message is comming back as. Here's the error:
[Linker error] undefined reference to `WinMain@16'
ld returned 1 exit status

Thanks again,
Nate
Behind every great gymnast - is a mentally unstable coach.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,413
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1470
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Help please, getting this to compile (using Dev C++)

 
0
  #3
Sep 10th, 2005
you probably created the wrong kind of project. You should have created a Console Application, not a Windows Application. With a Console Application your program compiled with no errors or warnings. Of course I had to add a main() function to the code you posted.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 48
Reputation: Coach_Nate is an unknown quantity at this point 
Solved Threads: 0
Coach_Nate's Avatar
Coach_Nate Coach_Nate is offline Offline
Light Poster

Re: Help please, getting this to compile (using Dev C++)

 
0
  #4
Sep 11th, 2005
Thanks, but I didn't even make it an application of either type to begin with. I just opened up new source files each time, and saved them as a .h and .cpp files. I also had another .cpp file that I was using in conjunction... here's the code for that one:
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include "SmpMth.h"
  4. using namespace std;
  5.  
  6. //This is only a test driver for the SmpMth class
  7.  
  8. int main()
  9. {
  10. int a,b;
  11. char var;
  12.  
  13. cout<<"******Min, Max & Add********\n"
  14. <<"\n\n";
  15.  
  16. cout<<"Add two numbers together: ";
  17. cin>>a,b;
  18. cout<<"\n" <<Add(a,b) <<"\n";
  19.  
  20.  
  21. system("PAUSE");
  22. return 0;
  23. }

Hope this helps a little more, sorry I didn't think to include it to begin with.
Behind every great gymnast - is a mentally unstable coach.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,413
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1470
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Help please, getting this to compile (using Dev C++)

 
0
  #5
Sep 11th, 2005
Originally Posted by Coach_Nate
Thanks, but I didn't even make it an application of either type to begin with. I just opened up new source files each time, and saved them as a .h and .cpp files.
Well, if you are going to use Dev-C++ then do it right. Create a project and then add the code to it.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC