title: Creating matrix using map container
body: <pre><code>   template &lt; class A, class B, class C&gt; class Matrix
    { 
      public:
  
     typedef map&lt;B,C&gt; M2; // for putting 1D info  
     typedef map&lt;A,M2&gt; M1;
     map&lt;M1, M2 &gt; data; 
     M1 m1;
     M2 m2;
     typedef  typename map&lt;B,C&gt;::iterator iterator2;
     iterator2 itr2; 
     typedef  typename map&lt;A,M2&gt;::iterator iterator1;
     iterator1 itr1;   
      Matrix()                             // default constructor
      { 
        m2.insert(pair&lt;int,double&gt; (1,10));
        m2.insert(pair&lt;int,double&gt; (2,20));
        m2.insert(pair&lt;int,double&gt; (3,30));
          m1.insert(pair &lt;int, M2&gt; (1,m2));
          m2.clear();
  
       m2.insert(pair&lt;int,double&gt; (1,40));
       m2.insert(pair&lt;int,double&gt; (2,50));
       m2.insert(pair&lt;int,double&gt; (3,60));
          m1.insert(pair &lt;int, M2&gt; (2,m2));
          m2.clear();
  
       m2.insert(pair&lt;int,double&gt; (1,70));
       m2.insert(pair&lt;int,double&gt; (2,80));
       m2.insert(pair&lt;int,double&gt; (3,90));
          m1.insert(pair &lt;int, M2&gt; (3,m2));
          m2.clear();                    }
  
  
  
      Matrix(const map&lt;M1, M2&gt;&amp; ar)              //copy constructor 
      { m1 = ar.m1; }
  
  
      Matrix&lt;A, B, C &gt;&amp; operator = (const Matrix&lt;A, B, C &gt;&amp; ass)    //assignment
      { if (this==&amp;ass) return *this;
        m1 = ass.m1; return *this; }
  
  
      const C&amp; operator () ( int&amp; index1,  int&amp; index2 )  //for accessing/modifying data
       {    itr1 = m1.begin();
            advance(itr1,  index1 - 1);
            m2 = (*itr1).second;  
            itr2 = m2.begin();
            advance(itr2,  index2 - 1);             
            return (*itr2).second;      }
   };
  
  
  int main()
  { 
    Matrix &lt;int,int,double&gt; mtr; 
  
     cout&lt;&lt; mtr(2,2);
  
      return 0;
    }
  </code></pre>
  
  <p>If I compile the above program I'm getting the following error "<code>cannot convert 'Matrix&lt;int, int, double&gt;' to 'double' in assignment.</code>"
  I think there is a problem in <em>the way I have tried to overload the operators</em> but have been unable to solve it so far...</p>
  
  <p>I know this isn't an efficient way of creating Matrices but since I'm a beginner ,it would help if you can help me understand the problem behind this code...  </p>
  
  <p>Problem Solved!
  Thanks</p>