Skip to content

Commit ef9e470

Browse files
committed
Add Lab 6 Program 4 Code
1 parent c9504a4 commit ef9e470

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include<iostream>
2+
#include<string.h>
3+
using namespace std;
4+
// DYNAMIC Constructor
5+
6+
class student
7+
{
8+
char *name;
9+
int roll;
10+
public:
11+
student()
12+
{
13+
14+
}
15+
student(char n[], int roll);
16+
void display();
17+
};
18+
void student::display()
19+
{
20+
cout<<name<<" "<<roll;
21+
}
22+
student::student(char n[],int roll_no)
23+
{
24+
name=new char[40];
25+
strcpy(name,n);
26+
roll=roll_no;
27+
}
28+
int main()
29+
{
30+
student s;
31+
student s1("xyz",10);
32+
s=s1;
33+
s1.display();
34+
s.display();
35+
}

0 commit comments

Comments
 (0)