这个问题如何解决?
这行出错:int *size=fill_array(properties,Max);
编译器显示错误信息如下:
Error] invalid conversion from 'int' to 'int*' [-fpermissive]
代码如下:
程序代码:
#include<iostream> const int Max=5; int fill_array(int ar[],int limit); void show_array(int ar[],int *n); void revalue(double r,int ar[],int *n); int main(){ using namespace std; int properties[Max]; int *size=fill_array(properties,Max); show_array(properties,size); if(*size>0){ cout<<"enter revaluation factor:"; double factor; while(!(cin>>factor)){ cin.clear(); while(cin.get()!='\n') continue; cout<<"bad input!"; } revalue(factor,properties,size); show_array(properties,size); } cout<<"Done.\n"; cin.get(); cin.get(); return 0; } int *fill_array(int ar[],int limit){ using namespace std; int temp; int i; for(i=0;i<limit;i++){ cout<<"enter value #"<<(i+1)<<":"; cin>>temp; if(!cin){ cin.clear(); while(cin.get()!='\n') continue; cout<<"bad input!"; break; } else if(temp<0) break; ar[i]=temp; } return ar+i; } void show_array(int ar[],int *u){ using namespace std; for(int i=0;(ar+i)!=u;i++){ cout<<"property #"<<(i+1)<<":$"; cout<<ar[i]<<endl; } } void revalue(double r,int ar[],int *n){ for(int i=0;(ar+i)!=n;i++) ar[i]*=r; }