I am writting two classes called Point and Edge The first one works ok, but the second, which has as members objects of the first one, is giving me an error I can't figure out. I am newbie to working with classes. The code is:
#include <iostream>
#include <math.h>
using namespace std;
class Point2D{
float x;
float y;
public:
Point2D();
Point2D(float);
Point2D(float,float);
float getx();
float gety();
void displayxy();};
class Edge{
Point2D pA;
Point2D pB;
public:
int a=888;
Edge();
Point2D CoordinateA();
float CoordinateAx();
float CoordinateAy();
Point2D CoordinateB();
float CoordinateBx();
float CoordinateBy();};
Point2D::Point2D(){
cout <<"First constructor called"<<endl;
x=0;
y=0;}
Point2D::Point2D(float xx){
cout <<"Second constructor called"<<endl;
x=xx;
y=0;}
Point2D::Point2D(float xx, float yy)
{ cout <<"Third constructor called"<<endl;
x=xx;
y=yy;}
float Point2D::getx(){return x; }
float Point2D::gety(){return y;}
void Point2D::displayxy(){cout<<"Coord x= "<<x<<" Coord y= "<<y<<endl;}
Edge::Edge(){Point2D pA(44,55); Point2D pB(66,77);}
float Edge::CoordinateAx(){return pA.getx();}
int main()
{ Edge side1();
cout <<side1.CoordinateAx()<<endl;
cout <<side1.CoordinateAy()<<endl;
//Point2D side1cA=side1.pA;;
return 1;
}
and the error:
C:\...\Poligoni\main.cpp|49|error: request for member 'CoordinateAx' in 'side1', which is of non-class type 'Edge()'|
C:\...\Poligoni\main.cpp|50|error: request for member 'CoordinateAy' in 'side1', which is of non-class type 'Edge()'|
which is referred to this two lines
cout <<side1.CoordinateAx()<<endl;
cout <<side1.CoordinateAy()<<endl;
Any idea?