开发者

Simple Constructor Initialization List

开发者 https://www.devze.com 2023-04-11 19:26 出处:网络
I want to开发者_开发问答 initialize one of the class variables to max of unsigned long long with something like this:

I want to开发者_开发问答 initialize one of the class variables to max of unsigned long long with something like this:

ClassA():
 maxvalue(std::numeric_limits<unsigned long long>::max())
{

}

Is it ok to do this? Can I use

std::numeric_limits<unsigned long long>::max()

in the intialization list?


Yes. This will work as long as maxvalue is able to be constructed from std::numeric_limits<unsigned long long>::max().

0

精彩评论

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

关注公众号