Classes and using a struct as a member?

Started by
12 comments, last by MARS_999 22 years ago
quote:Original post by MARS_999
is this correct seems to be working?

Looks OK, although it is of dubious design merit. Is it really necessary to have TGAFILE as a nested class?

quote:
Also I changed my header names to
#ifndef _TILES_H_
#define _TILES_H_

No, that''s wrong. The pattern underscore-capital-anytoken is reserved by the Standard. There are other such rules. If you are not aware of them, then never use leading undescores or double underscores anywhere in your code and you will be OK.
Advertisement
quote:Original post by SabreMan
Original post by MARS_999
is this correct seems to be working?

Looks OK, although it is of dubious design merit. Is it really necessary to have TGAFILE as a nested class?

quote:
Also I changed my header names to
#ifndef _TILES_H_
#define _TILES_H_

No, that''s wrong. The pattern underscore-capital-anytoken is reserved by the Standard. There are other such rules. If you are not aware of them, then never use leading undescores or double underscores anywhere in your code and you will be OK.

Thanks now I know about the underscore situation. On to the class nested struct for just a TGAFILE. I have a Sprite class that loads its own textures and updates everything so its just a slice of code from my class not all of it. Thanks

Bill Gates is my Pool Boy!!
Nothing is to good for me!!
Hi there,
I was wondering if anybody read my post

Well anyway. I agree with SabreMan in not using a nested class here. And I would do the initialisation of the members of TGAFILE in it''s constructor, but that''s just my 2 cents

NextS
quote:Original post by NextS
Hi there,
I was wondering if anybody read my post

Well anyway. I agree with SabreMan in not using a nested class here. And I would do the initialisation of the members of TGAFILE in it''s constructor, but that''s just my 2 cents

NextS


Oops sorry!! I just didnt'' understand the syntax you gave for the tga_file = new TGAFILE(); TGAFILE is a struct. So I used in my constructor tga_file = new TGAFILE; and that worked. Now I have a different problem with wanting to use a whole different class as an argument to a function of a different class. Each class is in it''s own .cpp and .h file. So I am having trouble getting that to work now. I am confused by what you mean by nested class? You mean don''t use a struct in a class? I need a struct for a TGAFILE to be able to load it. Or do you mean use the struct inside of the LOADTGA()? Problem with that is setting up texture parameters for each texture. Thanks all for helping and if you could answer my last few questions I would appreciate it. =)



Bill Gates is my Pool Boy!!
Nothing is to good for me!!

This topic is closed to new replies.

Advertisement