objects cpp code example
Example 1: how to write a class in c++
class Rectangle
{
int width, height;
public:
void set_values (int,int);
int area() {return width*height;}
};
void Rectangle::set_values (int x, int y)
{
width = x;
height = y;
}
Example 2: class cpp
class Exemple
{
private:
/* data */
public:
Exemple(); //Constructor
~Exemple(); //Destructor
};