Simple program that doesn't do anything much, but can anyone explain why copy constructor is not calling itself when an array of objects is passed in function argument? Works perfectly fine when only one object is initialized
class Student{
public:
Student(string name_val="empty",int tg=2019,int gu=0):
name{name_val},current_year{tg}{cout<<"Constructor is called "<<endl;}
Student(const Student &source):
name{source.name},current_year{source.current_year}{
cout<<"Copy constructor is called "<<endl;
}
~Student(){cout<<"Destructor is called "<<endl;}
void set(){
cout<<"Input name and surname: ";getline(cin,name);
}
private:
string name;
int current_year;
};
void input(Student s[],int n){//Should display when input function is called
for(int i=0;i<n;i++){
cout<<"Input data for "<<i+1<<". student\n";
s[i].set();
}
}
int main(){
Student S[2];//Calls constructor
input(S,2);//Should call copy constructor
return 0;
}