Typedef problem
Hi all,
I have a problem when wreiting the sorce of a member function.
When I try to comple the code it has a syntax error with the line befor the ''*''
FACE * DisplayObjects::getFaces(int type);
I had assumed that since I had decleared FACE type before the method I would be OK. I can''t seem to see anyother way.
Thanks in advnce.
(applogies about the code insersion).
=============Header Code===============================
#ifndef DISPLAYOBJECTS_H
#define DISPLAYOBJECTS_H
#include <allegro.h>
class DisplayObjects
{
private:
* This is used to store the four veticies that make a face which make up
* the cubes.
*/
typedef struct FACE
{
int v1, v2, v3, v4;
} FACE;
FACE faces1[18];
public:
// class constructor
DisplayObjects();
/**
* Returns the faces index array for the tive requested.
*/
FACE * getFaces(int type);
// class destructor
~DisplayObjects();
};
#endif // DISPLAYOBJECTS_H
=============Header Code End ===============================
=============Src code====================================
FACE *DisplayObjects::getFaces(int type)
{
if (type==1)
return faces1;
}
=============Src code END====================================
I usually don''t put the typedef statements in the class declaration. I don''t know if that''s because it doesn''t work that way or if it''s just my coding style.
quote:* This is used to store the four veticies that make a face which make up
* the cubes.
*/
All I can see is that your comment is missing an '/'
Regards Mats
Edit: One more thing...
You don't need the typedef.
struct FACE{ int v1, v2, v3, v4;};
[edited by - Matsen on March 8, 2003 10:04:13 AM]
Thanks guys,
It seems that if I keep the ''typedef'' and make it global it works, well it complies.
My applogies about the coding, it was a cut and paste job, as ther is a lot more code that would have clutter up the post.
Thanks again.
It seems that if I keep the ''typedef'' and make it global it works, well it complies.
My applogies about the coding, it was a cut and paste job, as ther is a lot more code that would have clutter up the post.
Thanks again.
From what I see. Correct me if I am wrong but you can''t declare a struct variable inside your class definition. Thats what constructors are for. You should take face out of the struct definition. Thats my take. Maybe I am wrong?
GGamer, since the struct is defined within the class DisplayObjects, you''ll probably need to type DisplayObjects::FACE instead of just FACE in your function...
MARS_999, GGamer wasn''t declaring an instance of the variable, he was just typedefing it, which is valid.
MARS_999, GGamer wasn''t declaring an instance of the variable, he was just typedefing it, which is valid.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement