Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This should be "almost" equivalent to your code. "almost", because as xDD said, the in-body definition of member function implicitly marks them as inline.</p> <p>Class are private by default and Struct are public by default.</p> <pre><code>template &lt;class KeyType, class ObjectType&gt; class Vertex { KeyType key; const ObjectType* object; public: Vertex(const KeyType&amp; _key, const ObjectType&amp; _object) : key(_key), object(&amp;_object) {} const KeyType getKey() { return key; } }; template &lt;class KeyType, class ObjectType&gt; class Graph { map&lt;KeyType, Vertex&lt;KeyType, ObjectType&gt; &gt; vertexes; public: const Vertex&lt;KeyType, ObjectType&gt;&amp; createVertex(const KeyType&amp; key, const ObjectType&amp; object) { Vertex&lt;KeyType, ObjectType&gt; *vertex = new Vertex&lt;KeyType, ObjectType&gt;(key, object); vertexes.insert(make_pair(vertex-&gt;getKey(), *vertex)); return *vertex; } }; </code></pre> <p>or with typedef :</p> <pre><code>template &lt;class KeyType, class ObjectType&gt; class Vertex { KeyType key; const ObjectType* object; public: Vertex(const KeyType&amp; _key, const ObjectType&amp; _object) : key(_key), object(&amp;_object) {} const KeyType getKey() { return key; } }; template &lt;class KeyType, class ObjectType&gt; class Graph { typedef Vertex&lt;KeyType, ObjectType&gt; tVertex; map&lt;KeyType, tVertex &gt; vertexes; public: const tVertex&amp; createVertex(const KeyType&amp; key, const ObjectType&amp; object) { tVertex *vertex = new tVertex(key, object); vertexes.insert(make_pair(vertex-&gt;getKey(), *vertex)); return *vertex; } }; </code></pre>
    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