online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <memory> #include <iostream> //----------------------------------------------------------------------------- // class_impl_itf.h // // start by defining an interface for your implementation // this allows the outer class to call functions without knowing // its implementation yet. class class_impl_itf { public: virtual int get_value() const noexcept = 0; virtual ~class_impl_itf() = default; protected: class_impl_itf() = default; }; //----------------------------------------------------------------------------- // class.h // #include "class_impl_itf.h" class class_t final { public: explicit class_t(int value); ~class_t() = default; // define the compare operator friend inline auto operator<=>(const class_t& lhs, const class_t& rhs) { return lhs.m_pimpl->get_value() <=> rhs.m_pimpl->get_value(); } private: // do not directly refer to the implementation class but its interface std::unique_ptr<class_impl_itf> m_pimpl; }; //----------------------------------------------------------------------------- // class_impl.h // #include "class_impl_itf.h" class class_impl_t final : public class_impl_itf { public: explicit class_impl_t(int value); int get_value() const noexcept override; private: private: int m_value; }; //----------------------------------------------------------------------------- // class.cpp // #include "class.h" // #include "class_impl.h" // class_t source file class_t::class_t(int value) : m_pimpl{std::make_unique<class_impl_t>(value)} { } //----------------------------------------------------------------------------- // class_impl.cpp // class_impl_t::class_impl_t(int value) : m_value{value} { } int class_impl_t::get_value() const noexcept { return m_value; } //----------------------------------------------------------------------------- // main.cpp // #include <class.h> int main() { class_t obj1{1}; class_t obj2{2}; if (obj1 < obj2) { std::cout << "obj1 < obj2"; } return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue