Sorry to just join the forum and already bring up an issue I'm having but, Visual Studio keeps saying that my functions are already declared/defined and it errors.... I've been reading on this for the past... weeks now... can someone tell/show me what I'm doing wrong here? Thank you in advance!
~ DarkPhoenix
Problems with classes and headers :/
-
- Posts: 3
- Joined: June 4th, 2012, 4:40 pm
Problems with classes and headers :/
- Attachments
-
- TextRPG.zip
- TextRPG
- (1.73 MiB) Downloaded 199 times
-
- Posts: 3
- Joined: June 4th, 2012, 4:40 pm
Re: Problems with classes and headers :/
If you don't want to download anything, here's the code that's giving me issues mostly:
Level.h
Level.cpp
Thanks again xD
~ DarkPhoenix
Level.h
Code: Select all
#ifndef LEVEL_H
#define LEVEL_H
class Level
{
private:
int level;
int exp;
int tnl;
int tempexp;
public:
Level();
int getLevel() {return level;}
void setLevel(int);
int getExp() {return exp;}
void setExp(int);
int getTNL() {return tnl;}
void setTNL(int);
int getTemp() {return tempexp;}
void setTemp(int);
void levelUp(int,int,int,int);
#endif
Code: Select all
#include "Level.h"
Level::Level()
:
level ( 1 ),
exp ( 0 ),
tnl ( 325 ),
tempexp ( 0 )
{}
void Level::setLevel(int l)
{
level = l;
}
void Level::setExp(int e)
{
exp = e;
}
void Level::setTNL(int t)
{
tnl = t;
}
void Level::setTemp(int temp)
{
tempexp = temp;
}
void Level::levelUp(int l, int e, int t, int temp)
{
if (temp > 0)
{
setExp(getExp() + temp);
setTemp(0);
if (e => t)
{
setLevel(getLevel() + 1);
tnl = t - e;
setTNL(((getLevel() * 100) + 1200) / 4);
}
}
}
~ DarkPhoenix
Re: Problems with classes and headers :/
You're missing a curly brace (and semicolon) after the class declaration. The begin class also lacks a semicolon after the curly brace.
These kinds of errors are often difficult to find, because the error often shows up in a different file.
These kinds of errors are often difficult to find, because the error often shows up in a different file.
-
- Posts: 3
- Joined: June 4th, 2012, 4:40 pm
Re: Problems with classes and headers :/
..... Completely forgot about that closing brace because I jumped into the .cpp after I finished the declaration >_>.... Thank you xD
~ DarkPhoenix
~ DarkPhoenix
Re: Problems with classes and headers :/
Hey uglypie, long time no see!
Thanks for answering this one bro.
Thanks for answering this one bro.
Chili