Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class student{
- int x;
- public:
- student(){ // default
- x = 67;
- }
- student(int a){ // parameterized
- x = a;
- }
- student(student & a){ // copy
- x = a.x;
- }
- void display(){
- cout<<x<<endl;
- }
- };
- int main()
- {
- student s1; // defalut
- student s2(40); // parameterized
- student s3(s2); // copy
- s1.display();
- s2.display();
- s3.display();
- return 0;
- }
- /*
- Output
- 67
- 40
- 40
- */
Advertisement
Add Comment
Please, Sign In to add comment