C++ Programming
09-23-2009, 03:30 AM
I have been trying to figure out what is wrong with this code. its probably something really obvious just that isn't clear to me. I would like any help that can be given, thanks.
int main(int argc,char* argv[])
{
Animals *ourAnimals[6];
Animals *goldfish = new Goldfish();
Animals *crocodile = new Crocodiles();
Animals *elephant = new Elephants();
Animals *gazelles = new Gazelles();
Animals *shark = new Sharks();
Animals *snakes = new Snakes();
ourAnimals[0]=goldfish;
ourAnimals[1]=crocodile;
ourAnimals[2]=elephant;
ourAnimals[3]=gazelles;
ourAnimals[4]=shark;
ourAnimals[5]=snakes;
string name, gender, weight;
name = "the Goldfish";
gender = "Female";
weight = "One Ounce";
goldfish -> setName(name);
goldfish -> setGender(gender);
goldfish -> setWeight(weight);
}
and this is the class
#pragma once
#include
#include
using namespace std;
class Animals
{
public:
Animals(void);
virtual ~Animals(void);
string getName() {return m_name;}
string setName(string &name){return m_name = name;}
string getGender(){return m_gender;}
string setGender(string &gender){return m_gender = gender;}
string getWeight(){return m_weight;}
string setWeight(string &weight){return m_weight = weight;}
virtual void goOut() = 0;
virtual void converse() = 0;
virtual void getBack() = 0;
protected:
string m_name;
string m_gender;
string m_weight;
};
it gives me an unhandled exception error.
this is my goldfish class
#pragma once
#include "marine.h"
class Goldfish :
public Marine
{
public:
Goldfish(void);
virtual ~Goldfish(void);
virtual void converse();
};
Goldfish::Goldfish(void)
{
}
Goldfish::~Goldfish(void)
{
}
void Goldfish::converse()
{
cout
int main(int argc,char* argv[])
{
Animals *ourAnimals[6];
Animals *goldfish = new Goldfish();
Animals *crocodile = new Crocodiles();
Animals *elephant = new Elephants();
Animals *gazelles = new Gazelles();
Animals *shark = new Sharks();
Animals *snakes = new Snakes();
ourAnimals[0]=goldfish;
ourAnimals[1]=crocodile;
ourAnimals[2]=elephant;
ourAnimals[3]=gazelles;
ourAnimals[4]=shark;
ourAnimals[5]=snakes;
string name, gender, weight;
name = "the Goldfish";
gender = "Female";
weight = "One Ounce";
goldfish -> setName(name);
goldfish -> setGender(gender);
goldfish -> setWeight(weight);
}
and this is the class
#pragma once
#include
#include
using namespace std;
class Animals
{
public:
Animals(void);
virtual ~Animals(void);
string getName() {return m_name;}
string setName(string &name){return m_name = name;}
string getGender(){return m_gender;}
string setGender(string &gender){return m_gender = gender;}
string getWeight(){return m_weight;}
string setWeight(string &weight){return m_weight = weight;}
virtual void goOut() = 0;
virtual void converse() = 0;
virtual void getBack() = 0;
protected:
string m_name;
string m_gender;
string m_weight;
};
it gives me an unhandled exception error.
this is my goldfish class
#pragma once
#include "marine.h"
class Goldfish :
public Marine
{
public:
Goldfish(void);
virtual ~Goldfish(void);
virtual void converse();
};
Goldfish::Goldfish(void)
{
}
Goldfish::~Goldfish(void)
{
}
void Goldfish::converse()
{
cout