Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It looks that <code>RCInput</code> is going to be just data, so you can lay it out like that:</p> <p><code>RCInput.h</code> file</p> <pre><code>class RCInput { public: RCInput(double x, double y, double z); double x() const; double y() const; double z() const; private: double m_x; double m_y; double m_z; }; </code></pre> <p><code>RCInput.cpp</code> file:</p> <pre><code>RCInput::RCInput(double x, double y, double z) : m_x(x), m_y(y), m_z(z) { } double RCInput::x() const { return m_x; } double RCInput::y() const { return m_y; } double RCInput::z() const { return m_z; } </code></pre> <p>Don't make it a nested class, put it in its own header file. This way the clients which use the inputs do not depend physically on the <code>RemoteControl</code> class header file. In my experience, nested classes are usually an unnecessary complication, they should be best avoided unless really necessary (e.g. iterators in containers).</p> <p>Also, don't yield to the temptation of making <code>RCInput</code> a struct with public data. You will lose all control over data accesses and creation of data, if you do so (no access logging in getters, no data validation in constructor, no place to set a debugger breakpoint). Remember that forward declaring a class/struct means that some other piece of code will need to be changed if you later decide to turn a <code>struct</code> into <code>class</code>, i.e. instead of</p> <p><code>struct RCInput;</code></p> <p>you will have to write</p> <p><code>class RCInput;</code></p> <p>It's better to make it a class from day 1.</p> <p>If you worry about performance, you can inline the getters.</p> <p>If you want to store <code>RCInput</code> in containers, add a public default constructor.</p> <p>If you want to control who can create <code>RCInput</code>, make the constructor private and declare the creating classes as friends (but that makes storing it in containers difficult).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload