Note that there are some explanatory texts on larger screens.

plurals
  1. POClass naming and namespaces
    primarykey
    data
    text
    <p>Will using same class name within multiple namespaces get me into trouble? I also try to remove dependency to math library. What do you think about following design.</p> <p><strong>first file</strong></p> <pre><code>#define MATH_RECTANGLE_EXISTS namespace math { class Rectangle : Object2D { public: float perimeter(); float area(); float x,y,w,h; }; } </code></pre> <p><strong>other file</strong></p> <pre><code>#define GRAPHIC_RECTANGLE_EXISTS #ifndef MATH_RECTANGLE_EXISTS //is this a good idea to remove dependency? namespace math { class Rectangle { public: float x,y,w,h; } } #endif namespace graphics { class Rectangle : math::Rectangle { public: void Draw(Canvas &amp;canvas); void Translate(float x, float y); }; } </code></pre> <p><strong>EDIT</strong></p> <p>What about this approach to remove dependency?</p> <p>** 1st file**</p> <pre><code>namespace common { class Rectangle { float x,y,w,h; }; } </code></pre> <p><strong>math lib file</strong></p> <pre><code>#define MATH_RECTANGLE_EXISTS namespace math { class Rectangle : public common::Rectangle, public Object2D { public: float perimeter(); float area(); }; } </code></pre> <p><strong>graphic file</strong></p> <pre><code>#define GRAPHIC_RECTANGLE_EXISTS namespace graphics { #ifndef MATH_RECTANGLE_EXISTS class Rectangle : public math::Rectangle { #else class Rectangle : public common::Rectangle { #endif public: void Draw(Canvas &amp;canvas); void Translate(float x, float y); }; } </code></pre> <p>Thanks in advance.</p>
    singulars
    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. This table or related slice is empty.
    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