Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C++ try run problem??

Status
Not open for further replies.

ach8

Technical User
Jul 7, 2003
3
MY
Hi, I'm new to the C++ programing and have try to write a small program for testing but is not working and with some error. Anyone here can help??


#include <iostream.h>
#include <iomanip.h>

class Point
{
double x,y;
public:
double get_x(return x);
double get_y(return y);
};
//------------------------------------------------

Point::point (double x1, double y1)
{
x=x1;
y=y1;
}
void Point::changepos (doubble chaposx, double chaposy)
{
x+=chaposx;
y+=chaposy;
}
//-------------------------------------------------

void changepoint (Point)
{
if (T.get_x() < 0) || (T.get_y() < 0)
{ T.chapos (2,5);
cout << &quot;\nPoint x value is &quot;<<T.get_x();
cout << &quot;\nPoint y value is &quot;<<T.get_y();
}
else
cout << &quot;\nNo change of x and y&quot;;
}
//-------------------------------------------------

main ()
{
Point sample (6,-4);
cout << &quot;\nvalue of x : &quot;<<sample.get_x();
cout << &quot;\nvalue of y : &quot;<<sample.get_y();
changepoint (sample) ;
cout << &quot;\nvalue of x : &quot;<<sample.get_x();
cout << &quot;\nvalue of y : &quot;<<sample.get_y();
return 0;
}
 
1) This function is not declared in your .h file

void Point::changepos (doubble chaposx, double chaposy)

2) void changepoint (Point)
Surely this needs a type, i.e. void changepoint (Point &T)

But this is an OO forum, as has been pointed out and this is not really an OO problem.
K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top