Hi and thanks in advance for helping me out. I am writing a class in C++ called PolyLine.cc I am supposed to include prototypes for all my methods in a header file (PolyLine.h). I am working on a unix server using the GNU compiler.
I have experience in Java and a little in C but this is my first real C++ program. So far my PolyLine.h file looks like this:
#ifndef PolyLine_h
#define PolyLine_h
#include <iostream.h>
class PolyLine
{
public:
ostream & operator <<(ostream& os, const PolyLine& p1);//operator <<
PolyLine(double *x, double *y, int len);// c-tor
PolyLine(const PolyLine& src);//copy c-tor
PolyLine& operator=( PolyLine& src);// operator =
~PolyLine ();//d-tor
int points();
double value(double x);
double max();
double max(double x1, double x2);
private:
double *xArray;
double *yArray;
int length;
};
#endif
and my PolyLine.cc file looks like this:
#include "PolyLine.h"
#include <iostream.h>
ostream& operator <<(ostream& os, const PolyLine& p1)
{return os;}
int points(){}
double value(double x){}
double max(){}
double max(double x1, double x2){}
PolyLine::PolyLine(double *x, double *y, int len){}
PolyLine::PolyLine(const PolyLine& src){}
PolyLine PolyLine& ::operator=( PolyLine& src)
{return *this;}
PolyLine::~PolyLine () {}
as you can see I have left the methods all empty in hopes of compiling it first and then expanding on it later but the complier returns the following error (borg is the name of the server I am working from):
borg:~/cs3132/a2$ g++ PolyLine.cc
In file included from PolyLine.cc:1:
PolyLine.h:8: `PolyLine::operator <<(ostream &, const PolyLine &)' must take exactly one argument
PolyLine.cc:12: syntax error before `&'
I am sure that operator << can take more than one argument, not sure why I am getting this error. If someone out there can help me, please do! =)
thank you very much for your time in any event. Happy coding