1class Object {
2public:
3 int var;
4 void setVar(int n) {
5 var = n;
6 }
7 int getNum() {
8 return var;
9 }
10};
11
12int main() {
13 Object obj;
14 obj.setVar(13);
15 std::cout << obj.getNum() << std::endl;
16 return 0;
17}
1class Rectangle
2{
3 int width, height;
4public:
5 void set_values (int,int);
6 int area() {return width*height;}
7};
8
9void Rectangle::set_values (int x, int y)
10{
11 width = x;
12 height = y;
13}
1class Rectangle {
2 int width, height;
3 public:
4 void set_values (int,int);
5 int area (void);
6} rect;
1class Exemple
2{
3 private:
4 /* data */
5 public:
6 Exemple(); //Constructor
7 ~Exemple(); //Destructor
8};
1class SampleClass
2{
3 int a;
4public:
5 SampleClass(int v)
6 {
7 a=v;
8 }
9 int RetVal()
10 {
11 return a;
12 }
13};