Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  تتتتت
Language: C/C++
Code:
#include <iostream>
#include <math.h>

using namespace std;

class Point {
public:
    int x1,y1;
    void set_values (int x, int y)
    {x1=x; y1=y;}
};

class Square {
public:
    Point p1, p2;
    int length(){return  sqrt((p2.x1 - p1.x1) * (p2.x1 - p1.x1) + (p2.y1 - p1.y1) * (p2.y1 - p1.y1));}
    int area()
    {return  length() * length();}
};

class Cube: public Square {
public:
    int volume()
    {return  area() * length();}
};

int main()
{
 int cote;
 cout << "Point, square and cube" << endl;

 Point p1,p2;
 Square square1;
 Cube cube1;
 square1.p1.set_values(0,0);
 square1.p2.set_values(5,0);
 cube1.p1.set_values(0,0);
 cube1.p2.set_values(5,0);

 cout <<square1.area() << endl;
 cout <<cube1.volume() << endl;

}

          
Comments: