HI there,
I've been trying to implement a class of a ball i was given by an tutor but am having troubles.
She gave me:
TBall.h

class TBall
{
public:
double _radius; // defines the radius of the ball
TVector _position; // defines the position of the ball
TVector _velocity; // defines the velocity v0 of the ball
// Constructors
TBall();
TBall(const double& Radius, const TVector& Position, const
TVector& Velocity)
{_radius=Radius; _position=Position; _velocity=Velocity;};
// Selectors
double GetBallRadius() const {return _radius;};
TVector GetBallPosition() const {return _position;};
TVector GetBallVelocity() const {return _velocity;};
void DrawBall(); // Draws the ball
void CalculateVelocity(const TVector& velocity, const double&
seconds); // Assigns the ball a velocity
TVector CalcDistanceTravelled(const double& seconds) const;
// Calculates the distance traveled
void MoveBall(const double& seconds); // Moves the ball
};

TBall.cpp

#include "tball.h"

TBall::TBall()
{
// Assign default values for the attributes
// of the ball
_radius = 4.0;
_position = TVector(1.0, 1.0, 1.0);
_velocity = TVector(0.1, 0.0, 0.0);
}

void TBall::DrawBall()
{
glPushMatrix();
glTranslatef(_position.X(),
_position.Y(), _position.Z());
glutSolidSphere(_radius, 20, 20);
glPopMatrix();
}

Both the code segements have no errors within them (i have all the associated vector,matrix etc header files.
I believe my problem is how to implement it within the display loop.
I use &TBall::DrawBall; But the ball doesnt seem to appear. Has ayone got any advice on how i get this to work?

Is this clear? i hope it is.

Thanks in advance from me!

Well &TBall::DrawBall; is just a pointer to a function.

To actually call it, you need say TBall::DrawBall()

Maybe even

TBall theBall;
// init code
theBall.DrawBall();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.