开发者

C++ and initializing constants in separator files

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜