multiple definition of Character.getName()

Pages: 12
I have had a project rattling around in the back of my mind for about the past 16 years. It is an RPG game, but I work on it, a few years pass while I'm busy with other things, and then when I come back to it, there are errors that weren't there before. So I fix the errors, work on it for awhile, get distracted by other things, rinse, and repeat My current issue is I've got 37 errors relating to my Character class, which begets Ally and Enemy classes. I suspect that this is a circular dependency issue, but I can't see how. I've read most of the Headers and Includes article, all my classes are in their own individual header and source files; every .h file has it's #ifndef [CLASSNAME.H] #define [CLASSNAME.H]/#endif bit. This question will be spread out over several posts due to the Field 'Content' length restriction
My warnings:

/home/michael/projects/codeblocks/character.h|1|warning: extra tokens at end of #ifndef directive|
/home/michael/projects/codeblocks/character.h|2|warning: missing whitespace after the macro name|
/home/michael/projects/codeblocks/allyparty.h|1|warning: extra tokens at end of #ifndef directive|
/home/michael/projects/codeblocks/allyparty.h|2|warning: missing whitespace after the macro name|
/home/michael/projects/codeblocks/party.h|1|warning: extra tokens at end of #ifndef directive|
/home/michael/projects/codeblocks/party.h|2|warning: missing whitespace after the macro name|
/home/michael/projects/codeblocks/enemyparty.h|1|warning: extra tokens at end of #ifndef directive|
/home/michael/projects/codeblocks/enemyparty.h|2|warning: missing whitespace after the macro name|
/home/michael/projects/codeblocks/draw.h|1|warning: extra tokens at end of #ifndef directive|
/home/michael/projects/codeblocks/draw.h|2|warning: missing whitespace after the macro name|

My errors:

obj/Debug/character.o||In function `Character::getName()':|
/home/michael/projects/codeblocks/character.cpp|4|multiple definition of `Character::getName()'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|4|first defined here|
obj/Debug/character.o||In function `Character::setName(std::string)':|
/home/michael/projects/codeblocks/character.cpp|5|multiple definition of `Character::setName(std::string)'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|5|first defined here|
obj/Debug/character.o||In function `Character::getCurHP()':|
/home/michael/projects/codeblocks/character.cpp|7|multiple definition of `Character::getCurHP()'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|7|first defined here|
obj/Debug/character.o||In function `Character::setCurHP(int)':|
/home/michael/projects/codeblocks/character.cpp|8|multiple definition of `Character::setCurHP(int)'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|8|first defined here|
obj/Debug/character.o||In function `Character::getCurMP()':|
/home/michael/projects/codeblocks/character.cpp|10|multiple definition of `Character::getCurMP()'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|10|first defined here|
obj/Debug/character.o||In function `Character::setCurMP(int)':|
/home/michael/projects/codeblocks/character.cpp|11|multiple definition of `Character::setCurMP(int)'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|11|first defined here|
obj/Debug/character.o||In function `Character::getMaxHP()':|
/home/michael/projects/codeblocks/character.cpp|13|multiple definition of `Character::getMaxHP()'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|13|first defined here|
obj/Debug/character.o||In function `Character::setMaxHP(int)':|
/home/michael/projects/codeblocks/character.cpp|14|multiple definition of `Character::setMaxHP(int)'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|14|first defined here|
obj/Debug/character.o||In function `Character::getMaxMP()':|
/home/michael/projects/codeblocks/character.cpp|16|multiple definition of `Character::getMaxMP()'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|16|first defined here|
obj/Debug/character.o||In function `Character::setMaxMP(int)':|
/home/michael/projects/codeblocks/character.cpp|17|multiple definition of `Character::setMaxMP(int)'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|17|first defined here|
obj/Debug/character.o||In function `Character::getIMFileName()':|
/home/michael/projects/codeblocks/character.cpp|19|multiple definition of `Character::getIMFileName()'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|19|first defined here|
obj/Debug/character.o||In function `Character::setIMFileName(std::string)':|
/home/michael/projects/codeblocks/character.cpp|20|multiple definition of `Character::setIMFileName(std::string)'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|20|first defined here|
obj/Debug/character.o||In function `Character::getX()':|
/home/michael/projects/codeblocks/character.cpp|22|multiple definition of `Character::getX()'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|22|first defined here|
obj/Debug/character.o||In function `Character::setX(int)':|
/home/michael/projects/codeblocks/character.cpp|23|multiple definition of `Character::setX(int)'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|23|first defined here|
obj/Debug/character.o||In function `Character::getY()':|
/home/michael/projects/codeblocks/character.cpp|25|multiple definition of `Character::getY()'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|25|first defined here|
obj/Debug/character.o||In function `Character::setY(int)':|
/home/michael/projects/codeblocks/character.cpp|26|multiple definition of `Character::setY(int)'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|26|first defined here|
obj/Debug/character.o||In function `Character::getCurImage()':|
/home/michael/projects/codeblocks/character.cpp|28|multiple definition of `Character::getCurImage()'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|28|first defined here|
obj/Debug/character.o||In function `Character::setCurImage(int)':|
/home/michael/projects/codeblocks/character.cpp|29|multiple definition of `Character::setCurImage(int)'|
obj/Debug/character.o:/home/michael/projects/codeblocks/character.cpp|29|first defined here|
||error: ld returned 1 exit status|
||=== Build failed: 37 error(s), 20 warning(s) (0 minute(s), 0 second(s)) ===|
#ifndef CHARACTER
#define CHARACTER
#include <string>
using namespace std;

class Character
{
private:
string name;
int curHP;
int curMP;

int maxHP;
int maxMP;

int xPos;
int yPos;

string imageMapFileName;

int curImage;

public:
//Character(void);
//~Character(void);

string getName();
void setName(string n);

int getCurHP();
void setCurHP(int hp);

int getCurMP();
void setCurMP(int mp);

int getMaxHP();
void setMaxHP(int hp);

int getMaxMP();
void setMaxMP(int m);

string getIMFileName();
void setIMFileName(string fn);

int getX();
void setX(int x);

int getY();
void setY(int y);

int getCurImage();
void setCurImage (int ci);
};
#endif // CHARACTER
Last edited on
character.cpp:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "character.h"
using namespace std;

string Character::getName() {return name; }
void Character::setName(string name) {this->name = name;}

int Character::getCurHP() {return this->curHP; }
void Character::setCurHP(int hp) {this->curHP = hp; }

int Character::getCurMP() {return this->curMP; }
void Character::setCurMP(int mp) {this->curMP = mp; }

int Character::getMaxHP() {return this->maxHP; }
void Character::setMaxHP(int hp) {this->maxHP = hp;}

int Character::getMaxMP() {return this->maxMP; }
void Character::setMaxMP(int m) {this->maxMP = m; }

string Character::getIMFileName() { return this->imageMapFileName; }
void Character::setIMFileName(string fn) { this->imageMapFileName = fn; }

int Character::getX() {return xPos; }
void Character::setX(int x) {this->xPos = x; }

int Character::getY() { return this->yPos; }
void Character::setY(int y) {this->yPos = y; }

int Character::getCurImage() {return curImage;}
void Character::setCurImage (int ci) {this->curImage = ci; }
Hi,
So can you post your code? Without your code we would not know what is going on.
This is the only place in the entire project that these methods are defined. My class structure hierarchy is:
Ally <-Character
Enemy <- Character
AllyParty <- Party //Party of Allies
EnemyParty <- Party //Party of Enemies
Party
Draw //Responsible for drawing everything in the game.
main.cpp
Ally and Enemy don't really do anything at this moment. I have replace all occurrences of Ally and Enemy objects with Character objects until I get my errors resolved.

ally.h:
1
2
3
4
5
6
7
8
9
10
11
12
#ifndef ALLY.H
#define ALLY.H
#include "character.h"

class Ally : public Character
{
public:
	//Ally(void);
	//~Ally(void);
};

#endif 

ally.cpp:
1
2
3
4
5
#include "ally.h"

//Ally::Ally(void) {}

//Ally::~Ally(void) {} 

I had some problem with the ctors in Ally and Enemy years ago, so I commented them out until such time as I could resolve the errors. Any code you see that's commented out had some problem in the past and will be uncommented when I find time to resolve said code's issues.
Last edited on
enemy.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifndef ENEMY.H
#define ENEMY.H
#include "character.h"
#include "enemy.h"


class Enemy :
	public Character
{
public:
	Enemy(void);
	~Enemy(void);

};

#endif 

enemy.cpp:
1
2
3
4
5
#include "enemy.h"

//Enemy::Enemy(void) {}

//Enemy::~Enemy(void) {} 
Last edited on
party.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef PARTY.H
#define PARTY.H
#include "character.h"


class Party
{
public:
	Party(void);
	~Party(void);
	virtual bool Include() = 0;
	void Exclude(Character character);
	virtual Character* getCharacter(int i) = 0;
	int getCount();
protected:
	int count;
};
#endif 

party.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "party.h"

Party::Party(void)
{
}

Party::~Party(void)
{
}



void Party::Exclude(Character character)
{
}

int Party::getCount() { return count; }

allyparty.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef ALLYPARTY.H
#define ALLYPARTY.H
#include "party.h"
#include "character.h"

const int MAXALLYCOUNT = 32;

class AllyParty :
	public Party
{
public:
	AllyParty(void);
	~AllyParty(void);
	bool Include();
	Character * getCharacter(int);
private:
	Character *chptr[MAXALLYCOUNT];
	int count;
};
#endif 

allyparty.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "allyparty.h"
#include "character.h"

AllyParty::AllyParty(void)
{
	for (int i = 0; i < MAXALLYCOUNT; i++)
	{
		chptr[i] = NULL;
	}
	count = 0;
}

AllyParty::~AllyParty(void)
{
	for (int i = 0; i < MAXALLYCOUNT; i++)
	{
		if (chptr[i] != NULL)
		{
			delete chptr[i];
			chptr[i] = NULL;
		}
	}
}

bool AllyParty::Include()
{
	if (count < MAXALLYCOUNT)
	{
		chptr[count] = new Character();
		count++;
		return true;
	}
	else
	{
		return false;
	}
}

Character* AllyParty::getCharacter(int i) { return chptr[i]; }

enemyparty.h:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef ENEMYPARTY.H
#define ENEMYPARTY.H

#include "character.h"
#include "party.h"

const int MAXENEMYCOUNT = 12;
class EnemyParty :
	public Party
{
public:
	EnemyParty(void);
	~EnemyParty(void);
	bool Include();
	Character * getCharacter(int);
private:
	Character* chptr[MAXENEMYCOUNT];
};
#endif 

enemyparty.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "enemyparty.h"

EnemyParty::EnemyParty(void)
{
	for (int i = 0; i < MAXENEMYCOUNT; i++)
	{
		chptr[i] = NULL;
	}
	count = 0;
}

EnemyParty::~EnemyParty(void)
{
	for (int i = 0; i < MAXENEMYCOUNT; i++)
	if (chptr[i] != NULL)
	{
		delete chptr[i];
		chptr[i] = NULL;
	}
}

bool EnemyParty::Include()
{
	if (count < MAXENEMYCOUNT)
	{
		chptr[count] = new Character();
		count++;
		return true;
	}
	else
	{
		return false;
	}
}

Character* EnemyParty::getCharacter(int i) { return chptr[i]; }

Before I post the Draw class, just let me say that when I hacked this together five or ten years ago I actually kind of understood what was going on. At this point I have no idea. The last time this program built successfully it all worked, so let's trust that it does for the moment...

draw.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef DRAW.H
#define DRAW.H

#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_ttf.h>
#include <SDL/SDL_gfxPrimitives.h>
#include "allyparty.h"
#include "enemyparty.h"
#include "character.h"

class Draw
{
public:
	Draw(void);
	~Draw(void);
	void Init();
	void draw(int);
	int getState();
	void setState(int i);
	void drawLines();
	void drawNames();
	void setAllyParty(AllyParty *p);
	void setEnemyParty(EnemyParty *p);
//      void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL );

private:
	SDL_Surface* SDL_ScaleSurface(SDL_Surface* Surface, unsigned int Width, unsigned int Height);
	unsigned int ReadPixel(SDL_Surface *surface, int x, int y);
	void DrawPixel(SDL_Surface *surface, int x, int y, unsigned int pixel);




	SDL_Surface *allyimage[4], *allynamearea[4], *allystatusarea[4], *enemyimage[12];
	Uint8 red, green, blue;
	SDL_Surface *screen;
	int state;
	AllyParty *allyparty;
	EnemyParty *enemyparty;
	Character *ally[4];
	Character *enemy[12];
	TTF_Font* font;





};
#endif 

draw.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
#include "draw.h"
#include <SDL.h>
#include <SDL_gfxPrimitives.h>
#include <string>
using namespace std;

SDL_Surface* Draw::SDL_ScaleSurface(SDL_Surface* Surface, unsigned int Width, unsigned int Height)
{
       if(!Surface || !Width || !Height) return 0;

        SDL_Surface *_ret = SDL_CreateRGBSurface(Surface->flags, Width, Height, Surface->format->BitsPerPixel,
	      Surface->format->Rmask, Surface->format->Gmask, Surface->format->Bmask, Surface->format->Amask);

	double  _stretch_factor_x = (static_cast<double>(Width)  / static_cast<double>(Surface->w)),
		_stretch_factor_y = (static_cast<double>(Height) / static_cast<double>(Surface->h));

	for(int y = 0; y < Surface->h; y++) //Run across all Y pixels.
	   for(int x = 0; x < Surface->w; x++) //Run across all X pixels.
	      for(int o_y = 0; o_y < _stretch_factor_y; ++o_y) //Draw _stretch_factor_y pixels for each Y pixel.
		 for(int o_x = 0; o_x < _stretch_factor_x; ++o_x) //Draw _stretch_factor_x pixels for each X pixel.
		    DrawPixel(_ret, static_cast<int>(_stretch_factor_x * x) + o_x,
			  static_cast<int>(_stretch_factor_y * y) + o_y, ReadPixel(Surface, x, y));
	return _ret;
}

unsigned int Draw::ReadPixel(SDL_Surface *surface, int x, int y)
{
    int bpp = surface->format->BytesPerPixel;
    /* Here p is the address to the pixel we want to retrieve */
    Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;

    switch(bpp) {
    case 1:
        return *p;

    case 2:
        return *(Uint16 *)p;

    case 3:
        if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
            return p[0] << 16 | p[1] << 8 | p[2];
        else
            return p[0] | p[1] << 8 | p[2] << 16;

    case 4:
        return *(Uint32 *)p;

    default:
        return 0;       /* shouldn't happen, but avoids warnings */
    }
}

void Draw::DrawPixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
{
    int bpp = surface->format->BytesPerPixel;
    /* Here p is the address to the pixel we want to set */
    Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;

    switch(bpp) {
    case 1:
        *p = pixel;
        break;

    case 2:
        *(Uint16 *)p = pixel;
        break;

    case 3:
        if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
            p[0] = (pixel >> 16) & 0xff;
            p[1] = (pixel >> 8) & 0xff;
            p[2] = pixel & 0xff;
        } else {
            p[0] = pixel & 0xff;
            p[1] = (pixel >> 8) & 0xff;
            p[2] = (pixel >> 16) & 0xff;
        }
        break;

    case 4:
        *(Uint32 *)p = pixel;
        break;
    }
}

//apply_surface came from http://lazyfoo.net/SDL_tutorials/lesson07/index.php
void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL )
{
    //Holds offsets
    SDL_Rect offset;

    //Get offsets
    offset.x = x;
    offset.y = y;

    //Blit
    SDL_BlitSurface( source, clip, destination, &offset );
}

/*****All code above this line waS NOT written by me***********************************************************************/


Draw::Draw(void)
{

}

Draw::~Draw(void)
{
}

void Draw::Init()
{


   	if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
	{
		printf("SDL failed to initialize: %s\n", SDL_GetError());
		exit(1);
	}


	if (TTF_Init() == -1)
	{
		printf("TTF_Init failed:  %s\n", TTF_GetError());
		exit(2);
	}


	screen = SDL_SetVideoMode(800, 600, 16, SDL_HWSURFACE || SDL_DOUBLEBUF);
	if (screen == NULL)
	{
		printf("SetVideo failed: %s\n", SDL_GetError());
		exit(1);
	}



	font = TTF_OpenFont("/usr/share/fonts/corefonts/arial.ttf", 18);
	if (font == NULL)
	{
	   printf("font is NULL\n");
	   exit(1);
	}

	SDL_Color foregroundColor = { 255, 255, 255 };
	SDL_Color backgroundColor = { 0, 0, 255 };



	char buff[100];
	for (int i = 0; i < 12; i++)
	{

		sprintf( buff, "%d", i);

		enemyimage[i] = TTF_RenderText_Shaded(font, buff, foregroundColor, backgroundColor);

	}





	SDL_WM_SetCaption("OurRPG", "OurRPG");

	red = 0;
	green = 0;
	blue = 0;
	SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, red, green, blue));

}
int Draw::getState() { return state; }
void Draw::setState(int i) { state = i; }
void Draw::setAllyParty(AllyParty *p)
{
	allyparty = p;
	Character* temp;
	for (int i = 0; i < 4; i++)
	{
		temp = allyparty->getCharacter(i);
		ally[i] = static_cast <Character*> (temp);
	}
	drawNames();

}
void Draw::setEnemyParty(EnemyParty *p)
{
	enemyparty = p;
	Character* temp;
	for (int i = 0; i < enemyparty->getCount(); i++)
	{
		temp = enemyparty->getCharacter(i);
		enemy[i] = static_cast <Character*> (temp);
	}
}
void Draw::draw(int state)
{
	SDL_Rect allysource[4], allydest[4], enemysource[12], enemydest[12];
	for (int i = 0; i < 12; i++)
	{
		enemyimage[i] = IMG_Load(enemy[i]->getIMFileName().c_str());
//		enemyimage[i] = SDL_ScaleSurface(enemyimage[i], 60, 30);
		enemysource[i].h = 50;
		enemysource[i].w = 50;
		enemysource[i].x = 0;
		enemysource[i].y = 0;

		enemydest[i].x = enemy[i]->getX();
		enemydest[i].y = enemy[i]->getY();
		enemydest[i].h = 50;
		enemydest[i].w = 50;
	}
	for (int i = 0; i < 4; i++)
	{
		allyimage[i] = IMG_Load(ally[i]->getIMFileName().c_str());


		allysource[i].h = 50;
		allysource[i].w = 50;
		allysource[i].x = 0;
		allysource[i].y = 0;


		allydest[i].x = ally[i]->getX();
		allydest[i].y = ally[i]->getY();
		allydest[i].w = 50;
		allydest[i].h = 50;
		SDL_BlitSurface(allyimage[i], &allysource[i], screen, &allydest[i]);
	}
	for (int i = 0; i < 12; i++)
	{
		SDL_BlitSurface(enemyimage[i], &enemysource[i], screen, &enemydest[i]);
	}

	drawLines();
	drawNames();


	SDL_Flip(screen);

}

void Draw::drawLines(void) //Draw the lines on the screen
{
//Main frame start
   lineRGBA(screen,
	 0, 0,
	 500, 0,
	 255, 255, 255, 255);

   lineRGBA(screen,
	 2, 0,
	 2, 400,
	 255, 255, 255, 255);

   lineRGBA(screen,
	 0, 400,
	 500, 400,
	 255, 255, 255, 255);

   lineRGBA(screen,
	 500, 0,
	 500, 400,
	 255, 255, 255, 255);

   lineRGBA(screen,
	 500, 0,
	 600, 0,
	 255, 255, 255, 255);
//Main frame end
   for (int i = 1; i<5; i++)
   {
      lineRGBA(screen,
	    500, (i*100),
	    600, (i*100),
	    255, 255, 255, 255);
   }

   lineRGBA(screen,
	 600, 0,
	 600, 400,
	 255, 255, 255, 255);




}
void Draw::drawNames(void) //Draw ally names and status bars
{
   SDL_Color textColor = {255, 255, 255};
   for (int i = 0; i<4; i++)
   {
      //Cycle through each ally and grab their name
      const char* c = ally[i]->getName().c_str(); //Convert our std:string to a const char*
      allynamearea[i] = TTF_RenderText_Solid(font, c, textColor);

      apply_surface( 505, i * 100, allynamearea[i], screen );
   }

}




And finally, main.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include "character.h"
#include "allyparty.h"
#include "enemyparty.h"
#include "draw.h"
#include <stdio.h>
#include <string>
using namespace std;

AllyParty *allyparty;
EnemyParty *enemyparty;
Draw draw;
int state;
const int WARRIOR = 0;
const int THIEF = 1;
const int BLACKBELT = 2;
const int REDMAGE = 3;
const int WHITEMAGE = 4;
const int BLACKMAGE = 5;



int main(int argc, char* argv[])
{

	draw.Init();

	allyparty = new AllyParty();
	enemyparty = new EnemyParty();
	Character *ally[4];
	Character *enemy[12];
	state = 0;
	Character* temp;
	for (int i = 0; i < 4; i++)
	{
		allyparty->Include();
		temp =  allyparty->getCharacter(allyparty->getCount() - 1);
		ally[i] = static_cast <Character*> (temp);
	}
	draw.setAllyParty(allyparty);
	draw.setState(state);

	int x = 0, y = 0;

	for (int i = 0; i < 12; i++)
	{
		if (!enemyparty->Include())
		{
			exit(1);
		}

	}
	for (int i = 0; i < 12; i++)
	{
		temp = enemyparty->getCharacter(i);
		enemy[i] = static_cast <Character*> (temp);
		enemy[i]->setName("Imp");
		enemy[i]->setIMFileName("imp.gif");

		if (i < 4) y = i * 100;
		if (i > 3)
		{
			if (i % 4 == 0)
			{
				y = 0;
			}
			else
			{
				y = (i % 4) * 100;
			}
		}

		enemy[i]->setY(y);
		if (i < 4) x = 0;
		if (i > 3 && i < 8) x = 100;
		if (i >= 8) x = 200;
		enemy[i]->setX(x);
//printf("enemy[%i] = (%i, %i)\n", i, x, y);
	}

	draw.setEnemyParty(enemyparty);





	ally[0]->setName("Michael");
	ally[0]->setX(400);
	ally[0]->setY(0);
	ally[0]->setIMFileName("warrior.gif");

	ally[1]->setName("Amy");
	ally[1]->setX(400);
	ally[1]->setY(100);
	ally[1]->setIMFileName("thief.gif");

	ally[2]->setName("Feli");
	ally[2]->setX(400);
	ally[2]->setY(200);
	ally[2]->setIMFileName("whitemage.gif");

	ally[3]->setName("Jelli");
	ally[3]->setX(400);
	//Y as in Y does she pee in the hallway?
	ally[3]->setY(300);
	ally[3]->setIMFileName("blackmage.gif");

	SDL_Event event;
	bool quit = false;
	while (!quit)
	{
	   draw.draw(0);

	   SDL_WaitEvent(&event);
	   switch (event.type)
	   {
	      case SDL_QUIT:
		 exit(0);
		 quit = true;
		 break;
	   }
	}








	//delete allyparty;
	return 0;
}


So that's all my code. I wrote most of it in vim, and then for this most recent try I've imported it into a Code:Blocks project. It is my first major mutifile C++ project, so I really want it to work so that I can do more. At this point I'm just a hobbyist programmer, but I really want to learn C++. Can anyone help me get rid of my 10 warnings and 37 errors?

You haven't posted character.h.
For the warnings:

The compiler mentions lines 1 and 2 of the file. You have your include guards #define statements there. So first stop see if you have the correct syntax look in the documentation :+) If you use an IDE, it should create these for you - so it should never be a problem. You could get away without them at all - use #pragma once instead. It's not standard, but is supported by most of the compilers.

For the errors, it could be a few things. I guess you could have those functions defined in the header file an d the cpp file. If the header guards aren't defined properly, then that could cause this problem also.
Dots are not allowed in macros.
1
2
#ifndef DRAW.H
#define DRAW.H 
Dots are not allowed in macros.

Huh... you learn a new thing every day!

Thanks, Thomas :)
character.h is up there. @Aug 3, 2016 at 9:23pm
Um, why is it I'm taking more effort to read your posts than you are? The thing you've labelled as "character.h" is pretty obviously not that file.
Pages: 12