huihut / interview

📚 C/C++ 技术面试基础知识总结,包括语言、程序库、数据结构、算法、系统、网络、链接装载库等知识及面试经验、招聘、内推等信息。This repository is a summary of the basic knowledge of recruiting job seekers and beginners in the direction of C/C++ technology, including language, program library, data structure, algorithm, system, network, link loading library, interview experience, recruitment, recommendation, etc.

Home Page:https://interview.huihut.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[discuss] inaccurate description

kingFighter opened this issue · comments

Quote
Reference to const
There is no const reference because the reference itself is a const pointer

reference is NOT an object, that's the reason why NO reference itself is const.

// class
class A
{
private:
    const int a;                // constant object member, can only be assigned in the initialization list
};

// constant object member, can only be assigned in the initialization list is not accurate, besides initialization list, we can use in-class initializer since C++11

// class
class A
{
private:
    const int a=1;                // constant object member, can only be assigned in the initialization list
};

It has been modified, thanks

Understand what functions C ++ silently writes and calls (the compiler secretly creates a default constructor, copy constructor, copy assignment operator, destructor for class)
C++11 secretly creates move constructor, move assignment operator , above is true before C++11. Better to put comment about it.