this is how you should split a class over .h and .cpp files and then be able to use in another cpp file...
Code:
Point.h
#include<iosfwd>
class Point
{
public:
Point();
Point(int,int);
~Point();
int GetX()const;
int GetY()const;
void SetXY(int,int);
friend std::ostream& operator << (std::ostream&,const Point&);
private:
int X;
int Y;
};
Code:
Point.cpp
#include "Point.h"
#include<iostream>
Point::Point() : X(0),Y(0) {}
Point::Point(int x,int y) : X(x),Y(y) {}
Point::~Point() {}
int Point::GetX()const { return X;}
int Point::GetY()const {return Y;}
void Point::SetXY(int x,int y) { X=x; Y=y;}
std::ostream& operator << (std::ostream& os,const Point& p)
{
os<<"( "<<p.X<<","<<p.Y<<" )";
return os;
}
Code:
Main.cpp
#include "Point.h"
#include <iostream>
int main()
{
Point p(10,10);
std::cout <<p<<std::endl;
p.SetXY(20,20);
std::cout<<p<<std::endl;
return 0;
}
Not windows specific but will give you the idea.