Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Issues with structs and Classes

This topic is 5921 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to declare a struct inside a class? I seem to be having a crash issues since I declared a struct inside my class. Here is my code ...

#ifndef Sprite_H
#define Sprite_H

class Sprite
	int armor;
	int speed;
	char *weapon1;
	char *weapon2;
	char *weapon3;
	char *name;
	unsigned int textures[1];
	struct TGAFILE
	unsigned char imageTypeCode;
	short int     imageWidth;
    short int     imageHeight;
    unsigned char bitCount;
    unsigned char *imageData;

	void LoadTexture(void);
	void Draw(void);
	void Update(void);
	bool LoadTGAFile(char *filename, TGAFILE *tgaFile);

now for my sprite.cpp file

	armor = 0;
	speed = 0;
	weapon1 = "None";
	weapon2 = "None";
	weapon3 = "None";
	name = "None";
	myTGA->bitCount = ' ';
	myTGA->imageHeight = 0;
	myTGA->imageTypeCode = ' ';
	myTGA->imageWidth = 0;
not sure whats going on or the problem but am new to the whole class thing. Thanks Bill Gates is my Pool Boy!! Nothing is to good for me!! [edited by - Mars_999 on May 5, 2002 11:25:49 PM]

Share this post

Link to post
Share on other sites
jobless beat me to it.

Get rid of the pointer notation, and use . instead of ->

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!