Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Deleted special operations are propagated to derived class
#include <iostream> class IBase { public: IBase() = default; IBase(const IBase& other) = delete; IBase(IBase&& other) noexcept = delete; IBase& operator=(const IBase& other) = delete; IBase& operator=(IBase&& other) noexcept = delete; virtual ~IBase() = 0; virtual int GetProperty() const = 0; virtual void SetProperty(const int& property) = 0; }; inline IBase::~IBase() {} class Derived : public IBase { public: int GetProperty() const override { return m_property; }; void SetProperty(const int& property) override { m_property = property; }; private: int m_property{}; }; int main() { // One instance Derived aa; // Set "property" through a virtual method. aa.SetProperty(42); // Second instance Derived bb = aa; // This propery was set through virtual method. std::cout << "aa m_property: " << iBase.GetProperty() << "\n"; // This property was not set via copy assignment operator. See line 33 for more details. std::cout << "bb m_property: " << aBase.GetProperty() << "\n"; }
run
|
edit
|
history
|
help
0
Mock Interview Question
Derivation of the 0x9E3779B97F4A7C17u constant
Crow unordered_map Quiz
regimeketopdf
set/map equal_range bug in libc++
1337
Variadic Template: Make Index Sequence
Dash-D compiler flag example
Dequeue Array-Based Example
std::function copies