-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfun.cpp
More file actions
40 lines (38 loc) · 689 Bytes
/
fun.cpp
File metadata and controls
40 lines (38 loc) · 689 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
35
36
37
38
39
40
#include <iostream>
using namespace std;
class Line
{
public:
void setLength(double len);
double getLength(void);
Line(); // This is the constructor
~Line();
private:
double length;
};
// Member functions definitions including constructor
Line::Line(void)
{
cout << "Object is being created" << endl;
}
Line::~Line(void)
{
cout << "Object is being deleted" << endl;
}
void Line::setLength(double len)
{
length = len;
}
double Line::getLength(void)
{
return length;
}
// Main function for the program
int main()
{
Line line;
// set line length
line.setLength(6.0);
cout << "Length of line: " << line.getLength() << endl;
return 0;
}