-5
這是一門學校工作,用於製作計算區域和周長的程序 編譯器/語法錯誤「預計;在void之前」和「void void之前的預期主表達式」。 我不知道問題是否在頭文件中。我在哪裏犯錯?
#include"shape.h"
#include<iostream>
using namespace std;
Shapes::Shapes()//base class
{status=true;}
void Shapes::launch()
{cout<<"Which figure are we working on ?"<<endl;
cout<<"Square(1),Triangle(2),Rectangle(3);"<<endl;
cout<<"Circle(4) or regular polygons(5)"<<endl;
cin>>a;}
void Shapes::aime()//mistake here.
{ //switch to decide shape
if (status) switch(a){
case'1':{Square::Square()
void Square::readSide()//mistake too.
{cout<<"The length of one side in metres : \t";
cin>>side;}
void Square::getsPerimeter()//another mistake.
{cout<<"The perimeter is "<<(side*4)<<" metres."<<endl;}
void Square::getsArea(){cout<<"The Area is "<<(side*side)<<" squared
metres."<<endl;}//again.
}
case'2':{Triangle::Triangle()
void Triangle::readData()//mistake
{cout<<"The length of the base in metres : \t";
cin>>base;
cout<<"The length of the height in metres : \t";
cin>>height;}
void Triangle::gettArea()//error
{cout<<"The Area is "<<(height*base/2)<<endl;}
}
case'3':{Rectangle::Rectangle()
void Rectangle::readDatar()//error
{cout<<"The length in metres : \t";
cin>>length;
cout<<"The width in metres : \t";
cin>>width;}
void Rectangle::getrArea()//error
{cout<<"Area is "<<(length*width)<<" squared metres."<<endl;}
void Rectangle::getrPerimeter()
{cout<<"Perimeter is "<<(2*(length+width))<<" metres."<<endl;}
}
case'4':{Circle::Circle()
void Circle::readRadius(){cout<<"The length of the radius in metres : \t";
cin>>radius;}
void Circle::getCirc()//error
{cout<<"Circumference is "<<(2*3.14159*radius)<<" metres."<<endl;}
Circle::getcArea()//error
{cout<<"Area is "<<(radius*radius*3.14159)<<" squared metres."<<endl;}
}
case'5':{Polygon::Polygon()
void Polygon::readDatap(){cout<<"The number of sides : \t";//error
cin>>num;
cout<<"The length of one side in metres : \t";
cin>>pside;
cout<<"The length of the apothem in metres : \t";
cin>>apothem;}
void Polygon::getpPerimeter()//error
{cout<<"The perimeter is "<<(num*pside)<<" metres."<<endl;}
void Polygon::getpArea()//another error
{cout<<"The area is "<<(num*pside*apothem/2)<<" squared metres."<<endl;}
}
} //switch() terminated
} //aime() terminated
bool Shapes::run(){return status;}
//to keep the app open
//the classes are derived classes of the base class:Shapes
您好,歡迎StackOverflow上。請編輯您的問題以提供[最小化,完整和可驗證](http://stackoverflow.com/help/mcve)示例來說明您的問題。 –
請編輯您的代碼,並以更好的方式縮進它。如果您希望我們提供幫助,您還應該嘗試在最小代碼示例中重現您的錯誤。 – OutOfBound
我很確定這個錯誤包含一個行號。 – YSC