跪求C++编程

来源:百度知道 编辑:UC知道 时间:2024/06/09 19:23:33
题目:设计一个类用于完成以下功能:通过在类中某成员函数接收传递过来的数组和数组大小,并有一个布尔类型参数;
要求:当布尔类型参数值为真时,返回数组中最大值的下标。反之.

class booltest{
int a;
bool d;

public:
booltest(int b[],int n,bool c);
void returnarr();
};
booltest::booltest(int b[],int n,bool c){d=c;int max=b[0];
for(int i=0;i<n;i++){if(b[i]>=max){max=b[i];a=i;}}}
void booltest::returnarr(){if(d)cout<<"the num is "<<a<<endl;}
没有调试过,但就是这样的思路