i am having errors when i compile this code such as:

main_class.h(31) : error C2228: left of '.x' must have class/struct/union
1> type is 'float'
main_class.h(31) : error C2228: left of '.y' must have class/struct/union
1> type is 'float'
main_class.h(31) : error C2228: left of '.z' must have class/struct/union
This is my linked list code:

typedef struct position
{
	float x, y, z;
} 
position, rot;

class shape
{
private:
	position pos;
	float orientation;
	float rate;
	shape * next;
public:
	void draw (void);
	virtual void render();
	void setNext(shape * n)
	{
		next = n;
	};
	shape* getNext(void)
	{
		return next;
	};
};

void shape::draw (void)
{
	glPushMatrix();
	glTranslatef (pos.x, pos.y, pos.z);
	glRotatef(orientation, orientation.x, orientation.y, orientation.z);
	render();
	glPopMatrix();

	orientation += rate;
	if (orientation >= 360) 
	{
		orientation -= 360;
	}
}

shape * p;

Any help or tip wouuld be much appreciated

float orientation;

So, orientation is a floating point variable. So, how come this :

orientation.x

Or, did you intend it to be

rot.x

instead?

well this code was given by my professor so i am not very clear about the draw function. i know that the orientation in the glRotatef is wrong as orientation is a float and not a struct therefore it will give some error. should i create another struct call and put it into glrotatef??

Hmmm... Perhaps answer this question:

Which part(s) of this code are you responsible for? Are you expected to make your code fit with the provided code? Which section(s) of the code are provided?

ok this whole piece of code is given by my professor as a skeleton. So i am supposed to fit my code with the provided code and add more codes if possible. I was given an assignment to create 3 objects and display them and i have to use classes as well and also i have to use linked list to link the objects together. The linked list has to be traversed, and for each object, the draw()
function has to be called. The draw() function
should be able to move the object to its position, rotate the object to its current orientation, call a pure virtual function render() that is implemented at
the child class to draw the object. So far i still do not know what to do with my draw function.

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.