C++ Don’t know how to use header file. no matching constructor for initialization / candidate constructor not viable don’t know how to fix [duplicate]

  arguments, arrays, c++, constructor, header-files

I am trying to implement a buffer array but I keep getting errors I don’t know how to fix yet I am very new to this and I really don’t know how to debug and I would really appreciate it this is the error I’m getting below

This is my error:

BufferArraymain.cpp:9:23: error: no matching constructor for initialization of 'ArrayBufferNoDups'
    ArrayBufferNoDups rosterNoDups;
                      ^
./ArrayBufferNoDups.h:6:1: note: candidate constructor not viable: requires single argument 'rosterNoDups', but no arguments were provided
ArrayBufferNoDups(int rosterNoDups) : BufferArray(size);
^
./ArrayBufferNoDups.h:2:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
 class ArrayBufferNoDups: public BufferArray
       ^
BufferArraymain.cpp:27:25: error: no matching constructor for initialization of 'ArrayBufferWithDups'
    ArrayBufferWithDups rosterWithDups;
                        ^
./ArrayBufferWithDups.h:6:1: note: candidate constructor not viable: requires single argument 'rosterWithDups', but no arguments were provided
ArrayBufferWithDups(int rosterWithDups) : BufferArray(size);
^
./ArrayBufferWithDups.h:2:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
class ArrayBufferWithDups : public BufferArray

This is The code I have for BufferArray.h

#include <iostream>
using namespace std;

class BufferArray{
    //private variable for the methods
    protected:
    int BUFFER_SIZE;
    int *intArray;
    int numberOfElements;

    private:
    int locationOf(int val){
        for(int i=0; i<numberOfElements; i++){
            if(intArray[i] == val){
                return i;
            }
        }

return -1;
} 
   
   public: 
        BufferArray(int size);
    //calling the methods

        virtual bool insert(int val);
        bool fastRemove(int val);
        bool stableRemove(int val);
        bool find(int target);
        void display();
};

This is the code I have for ArrayBufferNoDupps.h

     #include "BufferArray.h"
     class ArrayBufferNoDups: public BufferArray
    {
    public:
    // parameterized constructor which calls BufferArray constructor
    ArrayBufferNoDups(int rosterNoDups) : BufferArray(size){
}
    
    bool insert(int val);
    
    };

This is the code I have for ArrayBufferNoDups.cpp

#include "ArrayBufferNoDups.h"
//insert value into array
ArrayBufferNoDups :: ArrayBufferNoDups(){
    

}
bool ArrayBufferNoDups:: insert(int val){
    if(!find(val)){
        return BufferArray::insert(val);
    }
    return false;
}

This is the code I have for ArrayBufferWithDups.h

#include "BufferArray.h"
    class ArrayBufferWithDups : public BufferArray
    {
    public:
    // parameterized constructor which calls BufferArray constructor
    ArrayBufferWithDups(int rosterWithDups) : BufferArray(size){
}
    int findAll(int val);
    int fastRemoveAll(int val);
    int stableRemoveAll(int val);
    
    };

This is what I have for ArrayBufferWithDups.cpp

#include "ArrayBufferWithDups.h"


int ArrayBufferWithDups:: findAll(int val){
    int cnt = 0;
    
    for(int i=0;i<this->numberOfElements;i++){
        if(values == intArray[i])
        cnt++;
}

    return cnt;
}

int ArrayBufferWithDups:: fastRemoveAll(int val){
    int cnt = findAll(val);
    for(int i=0;i<cnt;i++){
        this->fastRemove(val);
}
    return cnt;

}

int ArrayBufferWithDups:: stableRemoveAll(int val){
    int cnt = findAll(val);
    for(int i=0;i<cnt;i++){
        this->stableRemove(val);
    }
    return cnt;
}

This is the main to test it. BufferArraymain.cpp

#include <iostream>

#include "ArrayBufferNoDups.h"
#include "ArrayBufferWithDups.h"


    int main(){
        cout << "Testing ArrayBufferNoDups" << endl;
        ArrayBufferNoDups rosterNoDups;
        rosterNoDups.insert(3);
        rosterNoDups.insert(2);
        rosterNoDups.insert(3);
        rosterNoDups.insert(3);
        rosterNoDups.insert(4);
    
        rosterNoDups.display();
        
        cout << rosterNoDups.find(3) << endl;
    
        rosterNoDups.fastRemove(2);
        rosterNoDups.display();
    
        rosterNoDups.stableRemove(3);
        rosterNoDups.display();
    
        cout << "Testing ArrayBufferWithDups" << endl;
        ArrayBufferWithDups rosterWithDups;
        rosterWithDups.insert(1);
        rosterWithDups.insert(2);
        rosterWithDups.insert(4);
        rosterWithDups.insert(3);
        rosterWithDups.insert(3);
        rosterWithDups.insert(4);
    
        rosterWithDups.display();
    
        cout << rosterWithDups.find(3) << endl;
        rosterWithDups.fastRemove(2);
        rosterWithDups.display();
    
        rosterWithDups.fastRemoveAll(4);
        rosterWithDups.display();
    
        rosterWithDups.stableRemove(1);
        rosterWithDups.display();
    
        int cnt = rosterWithDups.stableRemoveAll(3);
        rosterWithDups.display();
        return 0;
    
    }

Please help me it would be greatly appreciated and also should I incorporate the ArrayBufferNoDups.h and the ArrayBufferWithDups.h into the BufferArray.h and how would I go about that if I should?

Source: Windows Questions C++

LEAVE A COMMENT