c语言error 1075,fatal error C1075

fatal error C1075

这个错误括号没有配备好的错误,比如应该有两个花括号,由于不小心少了一个括号。

今天我就碰到这样一个错误,示例如下:

/*头文件CBOX.h*/

#ifndef CBOX_H

#define CBOX_H

#include

using namespace std;

//#include

class CBox

{

public:

//Constructor definition

CBox(double lv=1.0,double wv=1.0,double hv=1.0)

:m_Length(lv),m_Width(wv),m_Height(hv)

{  //cout<

}

/*上面两行,如果变成{//cout<

double Volume()const

{ return m_Length*m_Width*m_Height; }

//Overload 'greater than' that

//compares volumes of CBox objects.

bool operator>(const CBox & aBox)const

{

return this->Volume() > aBox.Volume();//第二个Volume后的()勿少了

}//否则会出现连接错误或其它语法错误

bool operator>(const double & value)const

{

return this->Volume()>value;

}

//Destructor definition

// ~CBox()

//{//cout<

private:

double m_Length;

double m_Width;

double m_Height;

};

#endif

/*头文件CSamples.h*/

#ifndef CSAMPLES_H

#define CSAMPLES_H

#include

using namespace std;

#include

#include"CBOX.h"

template

class CSamples

{

public:

CSamples(const T values[],int count)

{//Constructor definition to accept an array of samples

m_Free = count<100?count:100;//Don't exceed the array

for(int i= 0;i

m_Values[i]=values[i];

}

//Constructor to accept a single sample

CSamples(const T & value)

{

m_Values[0]=value;

m_Free=1;

}

CSamples(){m_Free=0;}//   Nohing stored,so first is free

//Function to add a sample

bool Add(const T & value)

{

bool OK = m_Free<100;//Indicates there is a free place

if(OK)//  OK true,so store the values

m_Values(m_Free++)=Value;

return OK;

}

//Function to botain maximum sample

T Max()const

{

//Set first sample or 0 as maximum

T theMax=m_Free?m_Values[0]:0;

for(int i=1;i

if(m_Values[i]>theMax )

theMax=m_Values[i];//Store any larger sample

return theMax;

}

private:

T m_Values[100];

int m_Free;

};

#endif

/***********源文件*******************/

#include "CBOX.h"

#include "CSamples.h"

int main( )

{

CBox boxes[]={

CBox(8.0,5.0,2.0),

CBox(5.0,4.0,6.0),

CBox(4.0,3.0,3.0)

};

//Create the CSamples object to hold CBox objects

CSamplesmyBoxes(boxes,sizeof boxes/sizeof CBox);

CBox maxBox=myBoxes.Max(); //Get the biggest box

cout <

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值