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
Program_3
Linker error while taking the address of a constexpr variable
general
template specialization inheritance problem
hello world
First test
C++ Standard Template Library
Return temporary
Integer conversions
Throttle Example (Send two requests every two seconds)