标签:形式 ble this指针 eve 编译器 const成员函数 put 通过 members
1 // error: ci and ri must be initialized 2 ConstRef::ConstRef(int ii) 3 { // assignments: 4 i = ii; // ok 5 ci = ii; // error: cannot assign to a const 6 ri = i; // error: ri was never initialized 7 }
1 // ok: explicitly initialize reference and const members 2 ConstRef::ConstRef(int ii): i(ii), ci(ii), ri(i) { }
We must use the constructor initializer list to provide values for members thatare const, reference, or of a class type that does not have a default
constructor
标签:形式 ble this指针 eve 编译器 const成员函数 put 通过 members
原文地址:https://www.cnblogs.com/2020R/p/13186601.html