-
Problem with classes
i have a class and it has these functions in it
Code:
void Modify(string member, int dat);
void Modify(string member, BITMAP *bmp);
int Access(string member);
and i get these errors
Code:
5 C:\Temp\Adam\linkedlist\main.cpp In file included from main.cpp
19 C:\Temp\Adam\linkedlist\SpriteHandler.h variable or field `Modify' declared void
19 C:\Temp\Adam\linkedlist\SpriteHandler.h expected `;' before '(' token
20 C:\Temp\Adam\linkedlist\SpriteHandler.h variable or field `Modify' declared void
20 C:\Temp\Adam\linkedlist\SpriteHandler.h expected `;' before '(' token
21 C:\Temp\Adam\linkedlist\SpriteHandler.h expected `;' before '(' token
the best i can come up with is the computer thinks that they are variables and not functions but i dont know how to change this
-
-
Code:
//class for a sprite handler that uses linked list
#ifndef SPRITEHANDLER_H
#define SPRITEHANDLER_H
#include <string>
#include <allegro.h>
#include <iostream>
class SpriteHandler
{
public:
SpriteHandler();
~SpriteHandler();
int Length();
bool Empty() const;
bool AtEnd();
void Modify(string member, int dat);
void Modify(string member, BITMAP *bmp);
int Access(string member);
void First();
void Next();
void Insert(const int &dat);/*,const int x, const int y, const int ...*/
void Update();
void Bounce();
void Move();
private:
struct node;
typedef node *node_ptr;
struct node
{
BITMAP *sprite;
int data;
int x,y;
int width, height;
int xspeed, yspeed;
int xdelay, ydelay;
int xcount, ycount;
int curframe, maxframe, animdir;
int framecount, framedelay;
node *next;
};
node_ptr myFirst, myCurrent, myPrevious;
int Size;
node_ptr GetNode(const int &dat);
};
#endif
-
Code:
//class for a sprite handler that uses linked list
#ifndef SPRITEHANDLER_H
#define SPRITEHANDLER_H
#include <string>
#include <allegro.h>
#include <iostream>
class SpriteHandler
{
public:
SpriteHandler();
~SpriteHandler();
int Length();
bool Empty() const;
bool AtEnd();
void Modify(string member, int dat);
void Modify(string member, BITMAP *bmp);
int Access(string member);
void First();
void Next();
void Insert(const int &dat);/*,const int x, const int y, const int ...*/
void Update();
void Bounce();
void Move();
private:
struct node;
typedef node *node_ptr;
struct node
{
BITMAP *sprite;
int data;
int x,y;
int width, height;
int xspeed, yspeed;
int xdelay, ydelay;
int xcount, ycount;
int curframe, maxframe, animdir;
int framecount, framedelay;
node *next;
};
node_ptr myFirst, myCurrent, myPrevious;
int Size;
node_ptr GetNode(const int &dat);
};
#endif
if you want the functions too i can add them but i get the same errors when they are commented out and when they arrent
-
add the scope operator to string... std::string.
-
Just add:
using namespace std;
after any #includes in your files. The functions contained in the header files, as well as the string type that is defined in <string>, need to be qualified by their namespace name: std.
-
i cant believe it is something that simple :) thanks alot though.