我遇到了一个C2106: '=' : left operand must be l-value
错误,
*shp[count]).area()=max;
我不确定这意味着什么。形状类是所有形状的基类,我试图将它们全部放在形状类型的数组中,并找出哪个具有最大的面积
int largestArea()
{
float max =-99999;
int index = 0;
shape *shp[6];
shp[0 ]= new trapezoid (4,6,3);
shp[1 ]= new triangle (4,2);
shp[2 ]= new parallelogram (3,8);
shp[3 ]= new trapezoid (2,6,3);
shp[4 ]= new triangle (5,2);
shp[5 ]= new parallelogram (2,7);
for(int count=0;count<6;count++)
{
if((*shp[count]).area()>=max)
{
(*shp[count]).area()=max;
index = count;
}
}
return index;