-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem_029.cpp
More file actions
35 lines (32 loc) · 758 Bytes
/
problem_029.cpp
File metadata and controls
35 lines (32 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//Write a program in c++ to demonstrate defult constructor.Create a class
//having two data members in the private section.Define a defult constructor to initialize these
//data members to initial value and display these values with the help of members
//function
#include<iostream>
using namespace std;
class Student{
private:
int age;
float marks;
public:
Student(int age,float marks);
void dispaly();
};
Student::Student(int age,float marks)
{
this->age=age;
this->marks=marks;
}
void Student::dispaly()
{
cout<<"Age:"<<age<<endl;
cout<<"Marks:"<<marks<<endl;
}
int main()
{
Student Rakesh(14,540.67);
Rakesh.dispaly();
Student Bimol(40,670.64);
Bimol.dispaly();
return 0;
}