gpt4 book ai didi

c++ - 自动生成的类成员?

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:28:57 25 4
gpt4 key购买 nike

在创建类时,我知道有 3 个构造函数/析构函数,如果您不指定它们,它们会自动生成。 operator= 也是自动创建的。

operator== 或任何其他比较运算符是自动生成的吗?是否创建了任何其他成员或成员函数? this 指针呢?

最佳答案

根据latest spec我可以找到,第 12.1 节指出:

12 Special member functions [special] 1 The default constructor (12.1), copy constructor and copy assignment operator (12.8), move constructor and move assignment operator (12.8), and destructor (12.4) are special member functions. [ Note: The implementation will implicitly declare these member functions for some class types when the program does not explicitly declare them. The implementation will implicitly define them if they are odr-used (3.2). ... ]

关于c++ - 自动生成的类成员?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14963163/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com