// CurrentProject.cpp : Defines the entry point for the console application.
//

// CurrentProject.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using namespace std;

class Animal {
public:
	Animal();
	~Animal();
	virtual void say() = 0;
	virtual int isFlying() = 0;
	virtual void move() = 0;
};

Animal::Animal() {
	cout << "Constructor of Animal\n";
}

Animal::~Animal() {
	cout << "Destructor of Animal\n";
}

class Dog: public Animal {
public:
	Dog(char *name);
	void say();
	int isFlying();
	void move();
protected:
	char *name;
};

Dog::Dog(char *name) {
	this->name = new char[strlen(name) + 1];
	strcpy(this->name, name);
}

Dog::~Dog() {
	delete[] name;
}

void Dog::say() {
	cout << "Woof, woof";
}

int Dog::isFlying() {
	return 0;
}

void Dog::move() {
	cout << name << " is walking on 4 legs\n";
}

class Poodle: public Dog {
public:
	Poodle(char *name);
	Poodle(const Poodle &otherPoodle);
	void move();
	const Poodle& operator=(const Poodle& otherPoodle);
};

Poodle::Poodle(char *name) : Dog(name) {
}

Poodle::Poodle(const Poodle &otherPoodle) : Dog(otherPoodle.name) {
	cout << "Copy constructor";
}


void Poodle::move() {
	cout << name << " is carried by the owner\n";
}

const Poodle& Poodle::operator=(const Poodle &otherPoodle) {
	cout << "Poodle to poodle assignment\n";
	this->name = new char[strlen(otherPoodle.name) + 1];
	strcpy(this->name, otherPoodle.name);
	return *this;
}

int _tmain(int argc, _TCHAR* argv[])
{
    //Animal a;
	Dog d("Champion");
	d.move();
	Dog *p = new Poodle("Toto");
	p->move();
	Poodle p2 = * ((Poodle*)p);
	Poodle p3("Mimi");
	p3.move();
	p3 = p2;
	p2.move();
	p3.move();
	delete p;
	return 0;
}



