-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoop_tut07.cpp
47 lines (36 loc) · 902 Bytes
/
oop_tut07.cpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
using namespace std;
// ---------------------> Constructor , Default arguments <-----------------------
class simple
{
int a, b, c;
public:
void display();
simple(int, int, int); // ---> Constructor
};
void simple ::display()
{
cout << "Enter the value of a ";
cin >> a;
cout << "Enter the value of b ";
cin >> b;
cout << "Enter the value of c ";
cin >> c;
cout << "The value of a,b and c is "<<a<<","<<b<<" and "<<c;
}
simple::simple(int x, int y, int z) // ----> Default arguments
{
a = x;
b = y;
c = z;
}
int main()
{
simple c1(1,2,3); // --> argument should be given due to Constructor need an argument
c1.display(); // to execute althouhg it does not have any impact on output.
// simple c2;
// c2.display();
// simple c3;
// c3.display();
return 0;
}