🔒 Locked
BYTE
Advertisement
Original Post
I''ve got a class that looks like this:
class Landscape
{
public:
Landscape(char* filename, int width, int height);
~Landscape();
void SetWidth(int NewWidth);
void SetHeight(int NewWidth);
int GetWidth();
int GetHeight();
Draw();
private:
int Width, Height;
BYTE Data[Width*Height];
};
when i change the last variable (DATA[Width*Height]) to int instead of BYTE it works just fine, but when i use BYTE it gives 8 errors:
(16) : error C2146: syntax error : missing '';'' before (16) : error C2501: ''BYTE'' : missing storage-class or type specifiers
(16) : error C2327: ''Landscape::Width'' : member from enclosing class is not a type name, static, or enumerator
(16) : error C2065: ''Width'' : undeclared identifier
(16) : error C2327: ''Landscape::Height'' : member from enclosing class is not a type name, static, or enumerator
(16) : error C2065: ''Height'' : undeclared identifier
(16) : error C2057: expected constant expression
(16) : error C2501: ''Data'' : missing storage-class or type specifiers
Error executing cl.exe.
What is wrong?
Thanx,
Marty
beware , the compiler is case sensitive, because it doesnt recognize BYTE as a type of variable it considers it to be a variable , you should use byte instead of BYTE , anyway consider that the use of byte in that class might reduce the memory usage but also limits you to 256 levels of height?(byte is an integer type)
---
sorry for not using proper english , I'm from latin roots
[edited by - lilken on February 18, 2003 9:41:08 AM]
---
sorry for not using proper english , I'm from latin roots
[edited by - lilken on February 18, 2003 9:41:08 AM]
alternatively, you can
typedef BYTE unsigned char
but since there might be a possibility of clashing, you should
call it something else, like MYBYTE or something
-eldee
;another space monkey;
[ Forced Evolution Studios ]
typedef BYTE unsigned char
but since there might be a possibility of clashing, you should
call it something else, like MYBYTE or something
-eldee
;another space monkey;
[ Forced Evolution Studios ]

Do NOT let Dr. Mario touch your genitals. He is not a real doctor!
the actual problem is that his variable Data is "dynamic" but it can only be static. You cant dynamically allocate a variable like this:
BYTE Data[Width*Height];
you'd need to define Data as a pointer to a byte array
byte *pData;
and when you know the width and height of the landscape, use pData=new byte[Width*Height];
remember to delete it using
delete [] pData;
[edited by - Dtag on February 18, 2003 10:22:30 AM]
BYTE Data[Width*Height];
you'd need to define Data as a pointer to a byte array
byte *pData;
and when you know the width and height of the landscape, use pData=new byte[Width*Height];
remember to delete it using
delete [] pData;
[edited by - Dtag on February 18, 2003 10:22:30 AM]
quote:
Original post by Marty666
when i change the last variable (DATA[Width*Height]) to int instead of BYTE it works just fine, but when i use BYTE it gives 8 errors...
it works with ints
Thanx for all the replies, it works now... BYTE was indeed a windows.h thing.
Another problem came up. When i resize a glut window it turns gray, while the clearcolor is 0,0,0,0... it only happenes when I also do drawing (triangles or quads)in my glutDisplayFunc. Also when i resize the aspect changes, but i used the following code, windW and windH are GLint. FOV is a const GLint = 45.
GLfloat aspect = windW/windH;
gluPerspective(FOV, aspect, 1.0, 100.0);
Strange stuff eh? Sometimes (when I resize again the triangles or quads are partly visible).
Marty
Another problem came up. When i resize a glut window it turns gray, while the clearcolor is 0,0,0,0... it only happenes when I also do drawing (triangles or quads)in my glutDisplayFunc. Also when i resize the aspect changes, but i used the following code, windW and windH are GLint. FOV is a const GLint = 45.
GLfloat aspect = windW/windH;
gluPerspective(FOV, aspect, 1.0, 100.0);
Strange stuff eh? Sometimes (when I resize again the triangles or quads are partly visible).
Marty
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement