|
-
June 30th, 2009, 02:17 PM
#1
Strange Errors, Possibly Bugged VS
After creating a new class called Environment I've been getting quite a bit of very strange errors:
- There were some before where although I included the header file VS would not recognize the symbols of the classes I included, but only for this one file I just created. After I restarted the program the errors went away and VS seemed to again recognize the classes.
- Now however the errors have seemed to return except in different ways. And restarting did not fix the problem.
The relevant code:
Code:
#include "Environment.h"
#include "../GLAddons/GLAddons.h"
#include "Avatar.h"
Environment::Environment()
{
salbrisAvatar = Avatar(3, 3, GLAddons::loadTexture("../Textures/Salbris.bmp"), this);
humanAvatar = Avatar(6, 6, GLAddons::loadTexture("../Textures/Human.bmp"), this);
}
With these errors:
Error 14 error C2512: 'Avatar' : no appropriate default constructor available
Error 15 error C2512: 'Avatar' : no appropriate default constructor available
Error 16 error C2661: 'Avatar::Avatar' : no overloaded function takes 4 arguments
Error 17 error C2661: 'Avatar::Avatar' : no overloaded function takes 4 arguments
Here's Environment.h:
Code:
#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H
#include "Avatar.h"
class Environment
{
private:
static const int GRID_WIDTH = 20;
static const int GRID_HEIGHT = 20;
char gridSpaces[GRID_WIDTH][GRID_HEIGHT];
Avatar salbrisAvatar;
Avatar humanAvatar;
void drawGrid(void) const;
public:
Environment();
~Environment();
void draw(void) const;
};
#endif
With error's on lines: "Avatar salbrisAvatar;" and "Avatar humanAvatar;"
Error 2 error C2146: syntax error : missing ';' before identifier 'salbrisAvatar'
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 5 error C2146: syntax error : missing ';' before identifier 'humanAvatar'
Error 6 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Here's Avatar.h:
Code:
#ifndef AVATAR_H
#define AVATAR_H
#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include "Environment.h"
class Avatar
{
private:
unsigned int positionX;
unsigned int positionY;
unsigned int textureId;
public:
static const float AvatarSize;
Environment *parent;
Avatar(unsigned int, unsigned int, unsigned int, Environment *);
~Avatar();
void draw(void) const;
void moveTo(unsigned int, unsigned int);
};
#endif
Avatar.h also has some errors:
- Line "Envrionment *parent" has the errors:
Error 10 error C2143: syntax error : missing ';' before '*'
Error 11 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 12 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- Line "Avatar(unsigned int, unsigned int, unsigned int, Environment *);" has the error:
Error 13 error C2061: syntax error : identifier 'Environment'
I've been working with C++ for a week and I've made many other classes, functions, etc. I've checked over these files many times but I can't seem to figure out what's wrong.
Any help would be greatly appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|