/*
Constructor Overloading
*/
#include<iostream>
#include<string.h>
using namespace std;
class Student
{
char name[20],course[20];
int fee;
public:
//Default Constructor
Student()
{
cout<<"\n\n Enter name,course and fee: ";
cin>>name>>course>>fee;
}
//Parameterized Constructor
Student(char n[],char c[],int f)
{
strcpy(name,n);
strcpy(course,c);
fee=f;
}
Student(char n[],char c[])
{
strcpy(name,n);
strcpy(course,c);
fee=0;
}
void display()
{
cout<<"\n\n Name: "<<name;
cout<<"\n Course: "<<course;
cout<<"\n Fee: "<<fee;
}
};
int main()
{
Student s1,s2("Atharv","OOP",1000),s3("Atharv","Python");
cout<<"\n\n 1: ";
s1.display();
cout<<"\n\n 2: ";
s2.display();
cout<<"\n\n 3: ";
s3.display();
return 0;
}
Constructor Overloading
*/
#include<iostream>
#include<string.h>
using namespace std;
class Student
{
char name[20],course[20];
int fee;
public:
//Default Constructor
Student()
{
cout<<"\n\n Enter name,course and fee: ";
cin>>name>>course>>fee;
}
//Parameterized Constructor
Student(char n[],char c[],int f)
{
strcpy(name,n);
strcpy(course,c);
fee=f;
}
Student(char n[],char c[])
{
strcpy(name,n);
strcpy(course,c);
fee=0;
}
void display()
{
cout<<"\n\n Name: "<<name;
cout<<"\n Course: "<<course;
cout<<"\n Fee: "<<fee;
}
};
int main()
{
Student s1,s2("Atharv","OOP",1000),s3("Atharv","Python");
cout<<"\n\n 1: ";
s1.display();
cout<<"\n\n 2: ";
s2.display();
cout<<"\n\n 3: ";
s3.display();
return 0;
}