开发者

C++ and initializing constants in separator files

开发者 https://www.devze.com 2023-04-03 22:23 出处:网络
I have a header file which declares the prototype for the constructor.In a separate file I have the constructor and all other methods declared outside the class. The constructor must initialize consta

I have a header file which declares the prototype for the constructor. In a separate file I have the constructor and all other methods declared outside the class. The constructor must initialize constants as well.

How do I define the prototype,开发者_高级运维 with the : constant_name(constant arg), etc.. or without and just write it in full form in the external file?


//---- prototype Some.h ----//

class Some {
    private: const int MAX_LENGTH;
    public:
        Some();
}

//---- implementation Some.cpp ----//

Some::Some() : MAX_LENGTH(512)
{
}
0

精彩评论

暂无评论...
验证码 换一张
取 消