Declaring class objects in a header file

前端 未结 3 1877
渐次进展
渐次进展 2021-01-12 05:11

Greetings everyone.

I seem to be snagging on a fundimental but I cant find the solution anywhere. Anywho, will go ahead and explain.

I have a program consist

3条回答
  •  半阙折子戏
    2021-01-12 05:52

    Use extern keyword. Declare these public objects as extern in header, then define instances in one of the cpps.

    Like this:

    extern SA Obj1; // in header
    
    SA Obj1;// in any one (no more than one) cpp
    

提交回复
热议问题