-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheapaccess.cpp
More file actions
45 lines (40 loc) · 1 KB
/
heapaccess.cpp
File metadata and controls
45 lines (40 loc) · 1 KB
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
/*
* =====================================================================================
*
* Filename: heapaccess.cpp
*
* Description: Demonstrating indirect access
*
* Version: 1.0
* Created: 03/01/13 20:28:23
* Revision: none
* Compiler: gcc
*
* Author: Robert Halliday (rh), rob_halliday_1@hotmail.com
* Company: rphhpr
*
* =====================================================================================
*/
#include <iostream>
using std::endl;
class SimpleCat
{
public:
SimpleCat() { itsAge = 2; }
~SimpleCat() {}
int GetAge() { return itsAge; }
void SetAge(int age) { itsAge = age; }
private:
int itsAge;
};
int main()
{
SimpleCat * Frisky = new SimpleCat;
std::cout << "Frisky is " << Frisky->GetAge()
<< " years old" << endl;
Frisky->SetAge(5);
std::cout << "Frisky is " << Frisky->GetAge()
<< " years old" << endl;
delete Frisky;
return 0;
}