Getting error in parameterised constructor
You need to pass a char array … c++ doesnt convert it implicitly.
Now it works fine.
#include <iostream>
#include<cstring>
using namespace std;
class student
{
int rno;
char name[20];
long long int prn;
public:
student()
{
rno=14;
strcpy(name,"bhavya");
prn=1814110631;
}
student(int r,long long int num,char arr[])
{
rno=r;
strcpy(name,arr);
prn=num;
}
void output()
{
cout<<" prn :"<<prn<<"\t"<<" name :"<<name<<"\t"<<"rno :"<<rno<<endl;
}
};
int main() {
student s;
s.output();
char pp[] = "pingu";
student s1(30,1814110651,pp);
s1.output();
}