Here's the abstract class
class number_sort{
public:
int num[1024];
int qww(int a);
public:
bool status;
int number=0;
virtual bool compare(int a, int b);
virtual void sort();
virtual bool test(int a[]);
virtual void setSet(int a[]);
};
Here's the derived class
class big_to_small:public number_sort{
public: int finish[1024];
void setSet(int a[]){
for(int i=1;i<=1024;i++){
if(a[i]!=0) {
num[i]=a[i];
number++;
}
}
}
bool compare(int a, int b) {
int retur = 0;
if (a >= b) {
retur = a;
status = true;
}
if (b >= a) {
retur = b;
status = false;
}
if (a == b) {
retur = a;
status = true;
}
return status;
}
bool test(int a[]) {
int numm = 0;
bool retur = true;
for (int i = 1; i <= 1024; i++) {
if (a[i] == 0) {
numm = i;
break;
}
}
for (int i = 2; i <= numm; i++) {
if (a[i - 1] < a[i]) {
retur = false;
break;
}
}
return retur;
}
void sort() {
for (int i = 2; i <= number; i++) {
if (!compare(num[i - 1], num[i])) {
int k = num[i - 1];
num[i - 1] = num[i];
num[i] = k;
}
}
if (!test(num))
sort();
}
};
I wrote the abstract class and its derivative in seperate cpp and hpp. In the main I declare the class using big_to_small bigg; but it keep showing build fail.
I haven't used C++ in a very long time, and I have been using java for the past few years. Is this some kind of declaration error or I wrote my abstract class wrong?