no matching function for call to ‘Mode::Mode()’

I am getting an error when I try to run my mode median mean program. What is causing this error.

Mode.h:41:29: error: no matching function for call to ‘Mode::Mode()’
Mode.h:19:5: note: candidates are: Mode::Mode(int*, int)
Mode.h:10:12: note: Mode::Mode(const Mode&)
Last edited on
The Rule of Three strikes again! You tried creating a "Mode" object without arguments without defining what to do in your code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

class Mode {
protected:
    int *b;//Sorted Array
    int bSize;//Size of Sorted Array;
    int max_Freq;//Frequency of the mode set,
    int num_Modes;//Number of Modes, size of Mode Array
    int *m;//Mode Array
    int *mark_Sort(int *,int);//Utility function for the class
public:
    Mode(int *pList, int nCount) // understand this is legal, this is the default constructor
    {
          // init things here but don't run anything.
    };
//    Mode(int *,int); // this is not.
    ~Mode(){//Constructor inputing the initial
        delete []b;
        delete []m;
    }

};
class Statistics:public Mode{ //This the line of error
protected:
    double sum;//Stores the sum of the array
    double average;//Stores the average of the sum of array
    int middle;//Store number of the array
    float median;
public:
     Statisticts(int *pList, int nCount)  // default constructor
           : Mode(pList, nCount)
    {
         // init the things specific to Statsticts here no function calls, just init varialbles
    }
        
    int set_Mean()const{
        
    }
    double get_Mean()const{
        return average;
}
    int set_Median()const{
        
    }
    int get_Median()const{
        return median;
    }
};

int main()
{
       int *pMylist;
       int nCount = 100;
       pMyList = new int(nCount);

       for(int nIndex = 0; nIndex <100; nIndex++)
       {
             pMyList[nIndex] = nIndex;
       }
      
       Mode myMode(pMyList, nCount); // this should just populate the object.
       // this is the first function on the object I want to run, ok so it copies data from one point to another.
       myMode.useData(); 
       // report what you found.
       myMode.ReportData();

       Statistics myStat(pList, nCount); // does what it needs in the mode constructor to init variables.
       MyStat.MessageVariables(); // local to stat may just call UseData() and other massaging functions..
       myStat.set_Median(); // stat function... 
       myStat.set_Mean(); // stat function.

       // should run the destructors here. 
       return 0;
       // exit code;
};
Last edited on
Topic archived. No new replies allowed.