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
	position pos;
	float orientation;
	float rate;
	shape * next;
	void draw (void);
	virtual void render();
	void setNext(shape * n)
		next = n;
	shape* getNext(void)
		return next;

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

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

shape * p;

Any help or tip wouuld be much appreciated

7 Years
Discussion Span
Last Post by Tiancailee
float orientation;

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


Or, did you intend it to be




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?

Edited by Fbody: n/a


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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.