Can anyone help me understand this error? “definition of implicitly-declared ‘classA::classA()’”

前端 未结 4 986
有刺的猬
有刺的猬 2021-01-07 17:33

Heres the code:

#include 
#include 
using namespace std;

class classA
{                   
      protected:
                v         


        
4条回答
  •  梦毁少年i
    2021-01-07 17:45

    You forgot to declare the constructor in the class definition. Declare it in public section of the class (if you want clients to create instance using it):

    class classA
    { 
          public: 
                  classA();    // you forgot this!       
          protected:
                    void setX(int a);
    
          private:
                  int p;
    };
    

    Now you can write its definition outside the class which you've already done.

提交回复
热议问题