Possible Duplicate:
Error on calling default constructor with empty set of brackets
When I run this I get the compiler warning:34 [Warning] the address of`Rational test4(), will always evaluate as true. but I am trying to make it so that the default constructor is the rational number 0/1. Line 34 is is int main() the line: cout << test4;.
#include <iostream>
using namespace std;
class Rational
{
public:
Rational();
friend ostream& operator <<(ostream& out,Rational rational1);
private:
int numerator;
int denominator;
};
int main()
{
//Rational test1(24,6), test2(24);
Rational test4();
//cout << test1<< endl;
//cout << test2<< endl;
cout << test4;
system("pause");
}
Rational::Rational() : numerator(0), denominator(1)
{
//empty body
}
ostream& operator <<(ostream& out,Rational rational1)
{
out << rational1.numerator <<"/"<<rational1.denominator;
return out;
}