Hello forum. I cant figure out how to overload the '+' operator or maybe theres another error? Im posting from phone so excuse the slopyness. Thanks!
#include <iostream>
#include <string.h>
#include <ctype.h>
using namespace std;
class Ferma
{
public:
static int nr_rate;
static int nr_gaini;
static int nr_porci;
static int nr_vaci;
virtual void afisare()
{
cout<<"Ferma:\n";
}
private:
int id;
string animal;
};
int Ferma::nr_rate=0;
int Ferma::nr_gaini=0;
int Ferma::nr_vaci=0;
int Ferma::nr_porci=0;
class Pasari:public Ferma
{
public:
Pasari(string s):animal(s)
{
if(s=="rata")
{
++nr_rate;
id=nr_rate;
cout<<"Tocmai am creeat rata"<<id<<"!"<<endl;
}
else if(s=="gaina")
{
++nr_gaini;
id=nr_gaini;
cout<<"Tocmai am creeat gaina"<<id<<"!"<<endl;
}
}
void afisare()
{
cout<<"animalul este "<<animal<<id<<endl;
}
Ferma