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
// compile with: g++ hello.cpp
#include<iostream>
#include<string>
#include<vector>
using namespace std;
// class is like struct... but
// - classes have methods - functions that run on the object
// - classes can make their data private
class myData {
private:
int x, y;
public:
myData(int n1, int n2) {
x = n1; y = n2;
}
myData() {
x = y = 0;
}
int getX() const {
return x;
}
void setX(int n) {
x = n;
}
int getY() const {
return y;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX