Can const member variable of class be initialized in a method instead of constructor?

前端 未结 5 1087
南方客
南方客 2021-02-10 07:56

I have a class and want to create a const int variable but the value for the variable is not available to me in constructor of the class.

In initialization method of the

5条回答
  •  温柔的废话
    2021-02-10 08:12

    Maybe what you can do, is change for a int pointer, receive this pointer in your constructor, and change the pointer where you want :P

    But it will not be the same functionnality cause it will be the pointer which is const and not anymore the value :/

提交回复
热议问题