首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

error C2296: '*' : illegal, left operand has type 'double *',该如何解决

2012-08-14 
error C2296: * : illegal, left operand has type double *#include stdafx.h#include iostream#

error C2296: '*' : illegal, left operand has type 'double *'
#include "stdafx.h"
#include "iostream"
#include "math.h"
#include "stdio.h"
using namespace std;
#define T 100

int main(int argc, char* argv[])
{
printf("Hello World!\n");

int n;
double a[T][3],i,j,p1[T] = {0},p2[T] = {1},area[T];
cin>>n;
for(i = 0;i < n;i++)
{
for(j = 0;j < 3;j++)
{
cin>>a[i][j];
p1[i] += a[i][j];
}
p1[i] = p1[i]/2.0;
}

for(i = 0;i < n;i++)
{
for(j = 0;j < 3;j++)
p2[i] *= (p1[i] - a[i][j]); 
area[i] = sqrt(p1[i] * p2[i]);
printf("%.3f",area[i]);
}
return 0;
}

error C2108: subscript is not of integral type
error C2108: subscript is not of integral type
error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'double (*)[3]' (or there is no acceptable conversion)
error C2108: subscript is not of integral type
error C2108: subscript is not of integral type
error C2108: subscript is not of integral type
error C2297: '+=' : illegal, right operand has type 'double (*)[3]'
error C2108: subscript is not of integral type
error C2108: subscript is not of integral type
error C2296: '/' : illegal, left operand has type 'double *'
error C2108: subscript is not of integral type
error C2108: subscript is not of integral type
Ferror C2108: subscript is not of integral type
error C2108: subscript is not of integral type
error C2040: '-' : 'double *' differs in levels of indirection from 'double (*)[3]'
error C2296: '*=' : illegal, left operand has type 'double *'
error C2108: subscript is not of integral type
error C2108: subscript is not of integral type
error C2108: subscript is not of integral type
error C2296: '*' : illegal, left operand has type 'double *'
error C2297: '*' : illegal, right operand has type 'double *'
error C2108: subscript is not of integral type

[解决办法]
数组的下标必须是int,而你的i,j是double

热点排行