Getting an error using my Constructor
Im getting this error
How is it thinking im trying to return something?
Classes.h:
[php]#include <iostream>
using namespace std;
class pokemon
{
public:
pokemon(int iAge, int iWeight, char iGender); //constructor and destructor
~pokemon();
int GetAge() { return cAge; } //accessor functions
void SetAge(int age) { cAge = age; }
int GetWeight() { return cWeight; }
void SetWeight(int weight) { cWeight = weight; }
int GetGender() { return cGender; }
void SetGender(char gender) { cGender = gender; }
void Retreat() { cout << "Retreated\n"; } //random function
private:
int cAge;
int cWeight;
char cGender;
}
[/php]
Main.cpp:
[php]#include "classes.h"
pokemon:
okemon(int iAge, int iWeight, char iGender) //constructor of pokemon,
//Im getting the error here.
//Says im trying to return something
{
cAge = iAge;
cWeight = iWeight;
cGender = iGender;
}
pokemon::~pokemon() {} //destructor
int main()
{
pokemon Pikachu(5, 15, 'F');
cout << "Age:\t" << Pikachu.GetAge() << '\n';
cout << "Weight:\t" << Pikachu.GetWeight() << '\n';
cout << "Gender:\t" << Pikachu.GetGender() << '\n';
}
[/php]
/
/
Code:
1>c:\users\patrick\documents\visual studio 2008\projects\more constructor practice\more constructor practice\main.cpp(4) : error C2533: 'pokemon::{ctor}' : constructors not allowed a return type
Classes.h:
[php]#include <iostream>
using namespace std;
class pokemon
{
public:
pokemon(int iAge, int iWeight, char iGender); //constructor and destructor
~pokemon();
int GetAge() { return cAge; } //accessor functions
void SetAge(int age) { cAge = age; }
int GetWeight() { return cWeight; }
void SetWeight(int weight) { cWeight = weight; }
int GetGender() { return cGender; }
void SetGender(char gender) { cGender = gender; }
void Retreat() { cout << "Retreated\n"; } //random function
private:
int cAge;
int cWeight;
char cGender;
}
[/php]
Main.cpp:
[php]#include "classes.h"
pokemon:
okemon(int iAge, int iWeight, char iGender) //constructor of pokemon, //Im getting the error here.
//Says im trying to return something
{
cAge = iAge;
cWeight = iWeight;
cGender = iGender;
}
pokemon::~pokemon() {} //destructor
int main()
{
pokemon Pikachu(5, 15, 'F');
cout << "Age:\t" << Pikachu.GetAge() << '\n';
cout << "Weight:\t" << Pikachu.GetWeight() << '\n';
cout << "Gender:\t" << Pikachu.GetGender() << '\n';
}
[/php]
/
/




talk about a mega-nerd.