943,503 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2133
  • C++ RSS
Feb 9th, 2005
0

C++ problem

Expand Post »
when i compile this, it gives me an error for my #include "Rationall.h" statement........i dont know why its giving me an error.




C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2.  
  3. using std::cout;
  4. using std::cin;
  5. using std::endl;
  6.  
  7. class rational {
  8.  
  9. public:
  10. rational();
  11. ~rational();
  12. int setrat( int x, int y);
  13. int getnum();
  14. int getdenom();
  15.  
  16.  
  17. private:
  18.  
  19. int numerator;
  20. int denominator;
  21.  
  22.  
  23. }; // end of rational class
  24.  
  25. rational::rational()
  26. {
  27. numerator = 1;
  28. denominator = 1;
  29. }
  30. int rational::setrat( int x, int y)
  31. {
  32. numerator = x;
  33. denominator = y;
  34. }
  35. int rational::getnum()
  36. {
  37. return (numerator);
  38. }
  39. int rational::getdenom()
  40. {
  41. return (denominator);
  42. }
  43.  
  44.  
  45. #include "Rationall.h"
  46.  
  47. int main()
  48. {
  49. int x, y;
  50. rational rationl;
  51.  
  52. cout << "Enter in a fraction" << endl;
  53. cout << "Enter in the numerator" << endl;
  54. cin >> x;
  55. cout << "Enter in the denominator" << endl;
  56. cin >> y;
  57.  
  58. rationl.setrat( x, y );
  59.  
  60. cout << "The fraction: " << endl;
  61. cout << rationl.getnum() << rationl.getdenom() << endl;
  62.  
  63. return 0;
  64. }
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
seeplusplus is offline Offline
25 posts
since Jan 2005
Feb 9th, 2005
0

Re: C++ problem

Me, too. (I don't have the file "Rationall.h" -- do you?)
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Feb 9th, 2005
0

Re: C++ problem

Dave,
Be nice to people, either answer their Q's or simply dont make fun of them, please.
-----------------
Save this in a file called Rationall.h

#include <iostream>

using std::cout;
using std::cin;
using std::endl;

class rational {

public:
rational();
~rational();
int setrat( int x, int y);
int getnum();
int getdenom();


private:

int numerator;
int denominator;


}; // end of rational class

rational::rational()
{
numerator = 1;
denominator = 1;
}
int rational::setrat( int x, int y)
{
numerator = x;
denominator = y;
}
int rational::getnum()
{
return (numerator);
}
int rational::getdenom()
{
return (denominator);
}
-------------
Save this in a file called Main.cpp

#include "Rationall.h"

int main()
{
using namespace std;
int x, y;
rational rationl;

cout << "Enter in a fraction" << endl;
cout << "Enter in the numerator" << endl;
cin >> x;
cout << "Enter in the denominator" << endl;
cin >> y;

rationl.setrat( x, y );

cout << "The fraction: " << endl;
cout << rationl.getnum() << rationl.getdenom() << endl;

return 0;
}
Reputation Points: 10
Solved Threads: 1
Light Poster
Intel is offline Offline
30 posts
since Feb 2005
Feb 10th, 2005
0

Re: C++ problem

Intel,
Let dave comment as he wishes and use code tags.
Reputation Points: 14
Solved Threads: 4
Junior Poster
prog-bman is offline Offline
108 posts
since Nov 2004
Feb 10th, 2005
0

Re: C++ problem

Quote originally posted by prog-bman ...
Intel,
Let dave comment as he wishes and use code tags.
Exactly.

You're not really helping by writing their code for them-- that's helping folks cheat.

Don't be a crutch.
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003
Feb 10th, 2005
1

Re: C++ problem

>Be nice to people, either answer their Q's or simply dont make fun of them, please.
<NOPOST>
Analyzing...

Dave Sinkula:
583 posts
Known guru
Nice and helpful

Intel:
11 posts
Does not seem very bright
Nice and gullible

Conclusion:
User "Intel" tries to act smart and pretend he knows what he is doing
User "Dave Sinkula" actually helps people

Searching database for appropriate response to user "Intel"...
</NOPOST>
Dave did answer the question. You're just not smart enough to look beyond your own ego and see it. Get over yourself, read the rules, and shut the hell up until you can post a quality response.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Feb 11th, 2005
0

Re: C++ problem

There is no need to be so harsh on intel, he is just starting out. He should have his freedom of speech and all these hostile responses wont make that easy.
Reputation Points: 113
Solved Threads: 3
Posting Whiz
Asif_NSU is offline Offline
353 posts
since Apr 2004
Feb 11th, 2005
0

Re: C++ problem

>He should have his freedom of speech
So should we. Everyone has a different style of teaching, and it's not Intel's place to dictate how we help people on a public voluntary forum.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Feb 11th, 2005
0

Re: C++ problem

Quote originally posted by Narue ...
>He should have his freedom of speech
So should we. Everyone has a different style of teaching, and it's not Intel's place to dictate how we help people on a public voluntary forum.
To me it sounded more like a request not a "dictation".
Reputation Points: 113
Solved Threads: 3
Posting Whiz
Asif_NSU is offline Offline
353 posts
since Apr 2004
Feb 11th, 2005
0

Re: C++ problem

>To me it sounded more like a request not a "dictation".
Just because a sentence fragment is terminated with "please" doesn't make the entire statement a request.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in C++ Forum Timeline: Console-input echo trouble
Next Thread in C++ Forum Timeline: Checkbook assignment help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC