C++简单的类继承问题

下面是我的代码,它会在子类的构造函数那里报错,像这样要怎么改呀?


BASE::BASE(int p1,int p2){
    mem1=p1;
    mem2=p2;
}
void BASE::display()const{
    cout<<"mem1="<<mem1<<",mem2="<<mem2<<endl;
}
int BASE::inc1(){
    mem1++;
}
DERIVED::DERIVED(int x1, int x2, int x3, int x4, int x5){
    BASE.BASE(x1,x2);
    mem4.BASE(x3,x4);
    mem3=x5;
}
int DERIVED::inc1(){
    mem3++;
}
void DERIVED::display() const{
    BASE.display();
    mem4.display();
    cout<<"mem3="<<mem3<<endl;
}

题目要求

img

下面是题目所给代码,完成两个类函数


#include <iostream>
#include <cstdlib>
//#include "DERIVED.h"

using namespace std;

int main() {
    
    DERIVED obj(17, 18, 1, 2, -5);
    obj.inc1();
    obj.display();


    return 0;
}
#ifndef DERIVED_H
#define DERIVED_H
//#include "BASE.h"

class DERIVED : public BASE{
    public:    
        DERIVED(int x1, int x2, int x3, int x4, int x5);
         int inc1() ;
         void display( ) const ;

    private:           
        int mem3;
        BASE mem4;
};


#endif
#ifndef BASE_H
#define BASE_H
#include <iostream>
using namespace std;

class BASE {
    public: 
        BASE(int p1, int p2);
        int inc1();    
        void display() const; 
    
    private:
        int mem1, mem2;
};                                 

#endif

1 在子类构造函数的初始化列表中直接调BASE()
2 子类构造中调用BASE::BASE()试试