Problem about //Constructor and //Destructor

Hello,
I'm having an error on //Constructor and //Destructor
Could someone please help.
Thanks

// Classes.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
// for cout
#include <vector>
// for vector
#include <string>
// for string
#include <fstream>
// for fileio
#include <cstdlib>
#include <time.h>
using namespace std;
class Animal {
private:
int height;
int weight;
std::string name;

static int numOfAnimals;

public:
int getHeight() { return height; }
int getWeight() { return weight; }
std::string getName() { return name; }
void setHeight(int cm) { height = cm; }
void setWeight(int kg) { weight = kg; }
void setName(std::string animalName) { name = animalName; }
// Declaring a prototype
void setAll(int, int, std::string);
// Constructor
Animal(int, int, std::string);
// Destructor
~Animal();
// Constructor that doesn't receive anything
Animal();

static int getNumofAnimals() { return numOfAnimals; }

void toString();
};

int Animal::numOfAnimals = 0;

void Animal::setAll(int height, int weight, std::string name) {

this -> height = height;
this -> weight = weight;
this->name = name;
Animal::numOfAnimals++;
}

void::Animal::toString() {

std::cout << this -> name << " is " << this -> height << " cms tall and " << this->weight << " kgs in weight " << std::endl;

}

class Dog : public Animal {

private:
std::string sound = "Woof";

public:
void getSound() { std::cout << sound << std::endl; }

Dog(int, int, std::string, std::string);

Dog() : Animal() {};

void toString();

};

Dog::Dog(int height, int weight, std::string name, std::string bark) :
Animal(height, weight, name) {

this -> sound = bark;

};

void Dog::toString() {

std::cout << this->getName() << " is " << this->getHeight() << " cms tall and " << this->getWeight() << " kgs in weight and says " << this->sound << std::endl;
}

int main()
{
Animal fred;

fred.setHeight(33);
fred.setWeight(10);
fred.setName("Fred");

std::cout << fred.getName() << " is " << fred.getHeight() << " cms tall and " << fred.getWeight() << "kgs in weight" << std::endl;

Animal tom(36, 15, "Tom");

std::cout << tom.getName() << " is " << tom.getHeight() << " cms tall and " << tom.getWeight() << "kgs in weight" << std::endl;

Dog spot(38, 16, "Spot", "Woof");

std::cout << "Number of Animals" << Animal::getNumofAnimals() << std::endl;

spot.getSound();

tom.toString();
spot.toString();

spot.Animal::toString();

return 0;
}

Topic archived. No new replies allowed.