I am trying to overload the << operator for my Currency class but I get this compiler error: C2143: syntax error : missing ';' before '&'
In my .h file I have:
friend ostream &operator << (ostream &, const Currency&);
And in my Currency.cpp file I have:
ostream &operator << (ostream &stream, const Currency &obj){
stream<<"$"<<obj.dollars<<"."<<obj.cents;
return stream;
}
Everything up until now worked fine, but choked once I put that in:
I have the following at the top of my .h file:
#ifndef CURRENCY_H
#define CURRENCY_H
#include<iostream>
#include<string>
#include<ostream>
#include<sstream>
class Currency; //forward delcaration
//Function prototypes for overloaded stream operators
ostream &operator << (ostream &, const Currency &);
I have no idea what I am doing wrong. Help would be great. Thanks