为什么虚拟分配的行为与同一签名的其他虚拟功能不同?
作者:David Rodríguez - dribeas 提问时间:6/9/2009
在玩实现虚拟赋值运算符时,我以一个有趣的行为结束了。这不是编译器故障,因为 g++ 4.1、4.3 和 VS 2005 具有相同的行为。 基本上,虚拟运算符 = 的行为与任何其他虚函数在实际执行的代...
继承 问答列表
作者:David Rodríguez - dribeas 提问时间:6/9/2009
在玩实现虚拟赋值运算符时,我以一个有趣的行为结束了。这不是编译器故障,因为 g++ 4.1、4.3 和 VS 2005 具有相同的行为。 基本上,虚拟运算符 = 的行为与任何其他虚函数在实际执行的代...
作者:rodrigocfd 提问时间:4/14/2017
我的库里有这两个类: class Base { int _handler; protected: Base() = default; Base& operator=(int h) { th...
作者:Jack 提问时间:5/8/2019
我有以下情况: 我有一个 Abstract 基类 No Copy 构造函数 无赋值运算符 有一些数据成员 派生类(派生自上面的基类) has 赋值运算符 有一些数据成员 当我们将一个派生类对象复...
作者:Hrant Nurijanyan 提问时间:3/9/2021
我正在使用 CRTP 来实现 C++ 功能。 现在我遇到了这样的情况。 template<typename T> struct A { char a; T operator+(const T...
作者:ZeroZ30o 提问时间:2/16/2023
我有以下结构: struct Feedback : public TaggedUnion<Feedback1Idx, String> { using TaggedUnion<Feedback1Id...
作者:Abhishek Mane 提问时间:7/7/2021
.h #ifndef header #define header struct base { private: int p,q; public: base(); base(const ba...
作者:carce-bo 提问时间:7/13/2022
我有以下类(例如): class A { public: A(void) : i(0) {} A(int val) : i(val) {} A(const A& other) : i(o...
作者:Stefan Nastase 提问时间:1/5/2021
我在钻石继承层次结构中有 4 个类。在课堂上称呼父母双方的作业操作员为作业操作员是否正确?它不会调用运算符= 2次吗?有没有更好的方法?der12base protected: int a = ...
作者:Igor 提问时间:8/4/2009
我有一个带有一组构造函数和一个赋值运算符的类。B 在这里: class B { public: B(); B(const string& s); B(const B& b) { (*thi...
作者: 提问时间:7/24/2019
我有一个基类 class Keyframebase { private: std::string stdstrName; float time; KeyframeType keyframeTy...