this is main file
#include <bits/stdc++.h>
#include "animal.h"
#include<sstream>
using namespace std ;
int main(){
Animal elephant("ele" ,12);
Animal cow("cow" ,22) ;
cow = elephant ;
cow.a[0]=5 ;
return 0 ;
}
this is Animal.h file
#ifndef ANIMAL_H
#define ANIMAL_H
#include<iostream>
#include<string>
using namespace std ;
class Animal{
string name ;
int age ;
public :
int a[] ;
Animal(string name , int age ):name(name) ,age(age) {}
Animal(const Animal & other);
};
#endif // ANIMAL_H
this is Animal.cpp
#include"animal.h"
#include<iostream>
using namespace std ;
Animal::Animal(const Animal & other){
cout<<"copy constructor is called"<<endl ;
this->age=other.age ;
this->name = other.name ;
}
I am not able to call the copy constructer ?? what is wrong with code . I have given all the files with their names and code .