Code:
include<iostream>
#include<math.h>
class point
{
int x;
int y;
int z;
public:
void setPoint()
{
std::cin>>x>>y>>z;
}
void printPoint()
{
std::cout<<"("<<x<<","<<y<<","<<z<<")"<<"\n";
}
void negatePoint()
{
std::cout<<"Negate of point is:("<<-x<<","<<-y<<","<<-z<<")\n";
}
#if 0
// This peice of code is blocked coz i cant understand what
// u want to do in distance point if u want to knw the distance
// of two points and return the diff
void distancePoint(const float distance)
{
point dis;
dis.x = pow 1(x,2)+ pow(y,2) +pow(z,2);
dis.y = sqrt(dis.x);
}
#else
point Distance(const point point_a,
const point point_b) {
point result;
result.x = point_a.x - point_b.x;
result.y = point_a.y - point_b.y;
result.z = point_a.z - point_b.z;
return result;
}
#endif
};
int main()
{
point a;
#if 0
clrscr(); // Sorry i m compiling with g++
#endif
a.setPoint();
a.printPoint();
a.negatePoint();
#if 0
a.distancePoint(); // Changed the signature u can use however u want :)
#endif
#if 0
getch(); // window's specific
#endif
return 0;
}
Check this out......
And i compiled this with g++ 4.3.2 on linux kernel 2.6.2
so microsoft specific function has been commented and abt distancepoint i dont understand what u want to do with that