C ++需要所有声明的类型说明符

时间:2016-11-10 10:52:29

标签: c++

我在“const MAX = 10”上收到错误“C ++需要所有声明的类型说明符”线。

这是我的代码:

//A program that adds up the maximum of 10 numbers ( 1,2,3,4,5,6,7,8,9,10 )


#include <iostream>
#include <cmath>
using namespace std;
const MAX = 10; //the error is here!

int main()
{
int sum, num;
sum = 0;
num = 1;

do
{
    sum = sum + num;
    num++;
}

while (num <= MAX);
{
    cout << "Sum = ";
}
return 0;
}

2 个答案:

答案 0 :(得分:2)

正如错误所说,C ++需要声明的类型说明符。例如,将//abstractmodal.service.ts @Injectable() export abstract class AbstractModel { abstract collection = []; constructor(private siteService: SiteService, private storageService: StorageService, private sweetalertService: SweetAlertService) {} setCollectionEmpty() { this.collection = []; } } //account-payable.service.ts @Injectable() export class AccountPayableService extends AbstractModel { public collection = []; constructor(private sS: SiteService,private stS: StorageService, private sws: SweetAlertService, private accpPoService: PayablePurchaseOrderService, private attachmentService: AttachmentService, private injectorService: InjectorService) { super(sS, stS, sws); } } //injector.service.ts @Injectable() export class InjectorService { constructor(private payrollService: PayrollService) {} cleanPayrollCollection() { this.payrollService.setCollectionEmpty(); } } //payroll.service.ts @Injectable() export class PayrollService extends AbstractModel { public collection = []; constructor(private sS: SiteService,private stS: StorageService, private sws: SweetAlertService, private accpService: AccountPayableService) { super(sS, stS, sws); } } 更改为$sdata['one'] = 'some value';

答案 1 :(得分:-4)

您是否考虑过使用

#define MAX 10