Good morning! I have to do this for an exercise:
Since the Square and Cube geometric figures are drawn from points, write a program that defines the Point, Square, and Cube classes. Proceed using inheritance;
So I think I did well? Anyway, I hope... However, there is a part that does not seem to work, the volume
#include <iostream>
#include <conio.h>
#include <ctype.h>
#include <stdio.h>
 
using namespace std;
 
//########### Définition de la classe Point ###########
class Point {
    public:
        Point(int x, int y) {
            this->x = x;
            this->y = y;
        }
 
        int getX() {
            return x;
        }
 
        int getY() {
            return y;
        }
 
    private:
        int x, y;
};
 
//########### Définition de la classe Carré ###########
class Square : public Point {
    public:
        Square(int x, int y, int side) : Point(x, y) {
            this->side = side;
        }
 
        int getArea() {
            return side * side;
        }
 
    private:
        int side;
};
 
 
//########### Définition de la classe Cube ###########
class Cube : public Square {
    public:
        Cube(int x, int y, int side) : Square(x, y, side) {
 
        }
 
        int getVolume() {
            return side * side * side;
        }
 
    private:
        int side;
};
 
 
int main() {
 
    Cube cube(1, 1, 2);
 
    cout << cube.getX() << endl; // 1
    cout << cube.getY() << endl; // 1 
    cout << cube.getArea() << endl; // 4 
    cout << cube.getVolume() << endl; // 8 
 
    return 0; 
}
But I don't know why it returns 0 in the volume :'c It should be simple though! It's just an int of the side * side * side;
But when i run it it shows me 1 1 4 0
Why does this happend to the cube.getVolume()?
 
     
    