Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: ATL programming Pin
CPallini22-Sep-09 2:38
mveCPallini22-Sep-09 2:38 
AnswerRe: ATL programming Pin
Rajesh R Subramanian22-Sep-09 4:35
professionalRajesh R Subramanian22-Sep-09 4:35 
Questionhow to set background color of menu and submenu in vc++ Pin
prerananit22-Sep-09 1:45
prerananit22-Sep-09 1:45 
AnswerRe: how to set background color of menu and submenu in vc++ Pin
Game-point22-Sep-09 2:00
Game-point22-Sep-09 2:00 
Questiondisplaying of context menu in richedittextbox control in vc++,mfc Pin
prerananit22-Sep-09 1:42
prerananit22-Sep-09 1:42 
AnswerRe: displaying of context menu in richedittextbox control in vc++,mfc Pin
Richard MacCutchan22-Sep-09 2:20
mveRichard MacCutchan22-Sep-09 2:20 
QuestionHow to call a method from soap base .net web service? Pin
bankey101022-Sep-09 1:23
bankey101022-Sep-09 1:23 
QuestionProblem with get/set method [modified] Pin
Sivyo22-Sep-09 0:16
Sivyo22-Sep-09 0:16 
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 <iostream>
#include <string>

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<<"The Gold fish speak:  "<<"Bloob Bloob"<<endl<<endl;
}



there is another derived class from Animal which is Called Marine in this case which looks like this

#pragma once
#include "animals.h"

class Marine :
	public Animals
{
public:
	Marine(void);
	virtual ~Marine(void);

	virtual void goOut();
	virtual void converse()= 0;
	virtual void getBack();
};


#include "Marine.h"

Marine::Marine(void)
{
}

Marine::~Marine(void)
{
}

void Marine::goOut()
{
	cout<<"The Marine animals:  "<<"swim out and are fed"<<endl<<endl;
}

void Marine::getBack()
{
	cout<<"The Marine animals:  "<<"Swim in"<<endl<<endl;
}




another thing to add is that if I move around the order of the protected variables. The error is always on the thrid variable


protected:
	string m_weight;
        string m_name;
	string m_gender; //error is here


modified on Tuesday, September 22, 2009 9:23 AM

AnswerRe: Problem with get/set method Pin
Nuri Ismail22-Sep-09 0:41
Nuri Ismail22-Sep-09 0:41 
GeneralRe: Problem with get/set method Pin
Sivyo22-Sep-09 1:33
Sivyo22-Sep-09 1:33 
GeneralRe: Problem with get/set method Pin
Nuri Ismail22-Sep-09 2:05
Nuri Ismail22-Sep-09 2:05 
GeneralRe: Problem with get/set method Pin
Sivyo22-Sep-09 2:17
Sivyo22-Sep-09 2:17 
GeneralRe: Problem with get/set method Pin
David Crow22-Sep-09 2:53
David Crow22-Sep-09 2:53 
GeneralRe: Problem with get/set method Pin
Sivyo22-Sep-09 9:45
Sivyo22-Sep-09 9:45 
AnswerRe: Problem with get/set method Pin
CPallini22-Sep-09 0:59
mveCPallini22-Sep-09 0:59 
GeneralRe: Problem with get/set method Pin
Sivyo22-Sep-09 1:39
Sivyo22-Sep-09 1:39 
QuestionRe: Problem with get/set method Pin
CPallini22-Sep-09 1:59
mveCPallini22-Sep-09 1:59 
AnswerRe: Problem with get/set method Pin
Sivyo22-Sep-09 2:05
Sivyo22-Sep-09 2:05 
GeneralRe: Problem with get/set method Pin
CPallini22-Sep-09 2:28
mveCPallini22-Sep-09 2:28 
GeneralRe: Problem with get/set method Pin
Sivyo22-Sep-09 3:18
Sivyo22-Sep-09 3:18 
AnswerRe: Problem with get/set method Pin
Richard MacCutchan22-Sep-09 2:32
mveRichard MacCutchan22-Sep-09 2:32 
QuestionRe: Problem with get/set method Pin
CPallini22-Sep-09 2:35
mveCPallini22-Sep-09 2:35 
AnswerRe: Problem with get/set method Pin
Richard MacCutchan22-Sep-09 6:07
mveRichard MacCutchan22-Sep-09 6:07 
AnswerRe: Problem with get/set method Pin
Sivyo22-Sep-09 3:21
Sivyo22-Sep-09 3:21 
GeneralRe: Problem with get/set method Pin
Richard MacCutchan22-Sep-09 6:05
mveRichard MacCutchan22-Sep-09 6:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.