Last active
April 11, 2018 04:02
-
-
Save mirajehossain/a82799777f98e5845b19489cb1a09214 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a student class and two overloading constructor which are takes parameters, | |
* create array of object and set two constructor dynamically and print information. | |
**/ | |
#include<iostream> | |
using namespace std; | |
class student | |
{ | |
public: | |
int id; | |
string name; | |
string department; | |
public: | |
student() {} | |
public: | |
student(int id) | |
{ | |
this->id = id; | |
cout<<"from 1 - "<<id <<endl; | |
} | |
public: | |
void printDetail() | |
{ | |
cout<< "name is: "<< name << " and ID is : "<<id<<endl; | |
} | |
public: | |
student(int id, string name) | |
{ | |
this->id = id; | |
this->name = name; | |
} | |
}; | |
int main() | |
{ | |
int i; | |
student st[3]; | |
for(i=0; i<=3; i++) | |
{ | |
int id; | |
string name; | |
cin>> id; | |
cin>> name; | |
st[i] = | |
{ | |
student(id,name) | |
}; | |
} | |
for(i=0; i<=3; i++) | |
{ | |
cout<<"ID : "<<st[i].id<<" and Name: "<<st[i].name<<endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment