954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C++ problem

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

#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);
}  


#include "Rationall.h"

int main()
{
   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;              
}
seeplusplus
Light Poster
25 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

Me, too. (I don't have the file "Rationall.h" -- do you?)

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

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

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;
}

Intel
Light Poster
30 posts since Feb 2005
Reputation Points: 10
Solved Threads: 1
 

Intel,
Let dave comment as he wishes and use code tags.

prog-bman
Junior Poster
109 posts since Nov 2004
Reputation Points: 14
Solved Threads: 4
 
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.

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 

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

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"...

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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

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.

Asif_NSU
Posting Whiz
353 posts since Apr 2004
Reputation Points: 113
Solved Threads: 3
 

>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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 
>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".

Asif_NSU
Posting Whiz
353 posts since Apr 2004
Reputation Points: 113
Solved Threads: 3
 

>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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You