-6
編寫程序以具有基類 編號 和兩個派生類: 正方形和立方體 。 你將計算平方數(A * A )和 立方數(A * A * A)爲什麼這個C++程序不能正常工作?
#include <iostream>
#include <conio.h>
using namespace std;
class Number
{
protected:
int a ;
int y;
public:
a*a = y;
a*a*a=y
};
class Square : Number
{
int a , y;
public:
(a*a) = y;
};
class Cube : Number
{
int a, y;
public:
(a*a*a) = y;
};
int main()
{
int a;
cout << "Enter number "<< endl;
cin >> a >>endl ;
cout << " the Square of this number is : " << (a*a);
cout << "Enter number ";
cin >> a;
cout << " the cube of this number is : " << (a*a*a);
return (0);
}
因爲它甚至不是遠程有效的C++代碼嗎? –
a * a = y?你想做什麼? – Bramsh
你應該從一個可以工作的「hello world」程序開始,並且建立在此之上;不試圖編碼一切,然後試圖讓它工作... –