I''m having some trouble with garbage values appearing when I run a program I created. (It is actually my first (very simple) class!)
#pragma hdrstop
#include <condefs.h>
#include <iostream.h>
#include <conio.h>
#pragma argsused
class point
{
public:
point(float,float,float);
~point();
void change(float,float,float);
display();
private:
float posx,
posy,
posz;
};
point::point(float x, float y, float z)
{
posx = x;
posy = y;
posz = z;
}
point::~point()
{
}
void point::change(float x, float y, float z)
{
posx = x;
posy = y;
posz = z;
}
point::display()
{
cout << "X: " << posx << endl;
cout << "Y: " << posy << endl;
cout << "Z: " << posz << endl;
}
int main()
{
point point_1(1.0,1.0,1.0);
cout << point_1.display(); //displays coords of point_1
point_1.change(1.5,2.6,24.56); //changes coords of point_1
cout << point_1.display(); //display new coords
getch();
}
And when I run it, this is the output:
X: 1
Y: 1
Z: 1
4335472X: 1.5
Y: 2.6
Z: 24.56
4335472
This value is somewhat random everytime I change my program. I''m sorry, I normally wouldn''t ask something like this here, but I''ve debugged and strained my brain for long enough!
Thanks!