Thread: overloading [] operator

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    673

    overloading [] operator

    I know how to overload the [] operator, but I cant seem to figure out how to to overload it so I can use the operator to access multidemensional arrays.
    my way to overload is
    Code:
    const type& operator[](const int& pos)
    {
       return Var[pos];
    }
    but clearly this doesnt work for multiple dimension. thanks for any assistance.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 07:05 AM
  2. Need help on understandind arrays
    By C++mastawannabe in forum C++ Programming
    Replies: 9
    Last Post: 06-16-2007, 10:50 PM
  3. Overloading [] operator for a vector
    By nappaji in forum C++ Programming
    Replies: 4
    Last Post: 05-01-2007, 10:44 AM
  4. operator overloading and dynamic memory program
    By jlmac2001 in forum C++ Programming
    Replies: 3
    Last Post: 04-06-2003, 11:51 PM
  5. Overloading the [] operator trouble
    By rmullen3 in forum C++ Programming
    Replies: 2
    Last Post: 08-01-2002, 12:46 PM