• VIEW THE 2025 QUANTNET RANKINGS.

FAQ: Advanced C++ and Modern Design Online Course

Concepts are the heaviest addition, and are really a paradigm shift.

Indeed, but once you get the hang of it it becomes easier.
I have lots of practical examples.

Really exciting. It's all got to do with deciding at which (meta) level to define and subsequently, use "things".

C++:
// Interface contract specification
template<typename T>
    concept IInput = requires (T x) { x.message(); };

template<typename T>
    concept IOutput = requires (T x, const std::string& s) { x.print(s); };

// I/O stuff
template <typename I, typename O> requires IInput<I> && IOutput<O>
    class SUD
{ // System under discussion, using composition

private:
    I i; O o;
public:
    SUD(const I& input, const O& output) : i(input), o(output) {}
    void run()
    { o.print(i.message());    }
};
 
Last edited:

Attachments

  • quantNet_HW1.webp
    quantNet_HW1.webp
    10.4 KB · Views: 8
Back
Top Bottom