overloading [] operator

This is a discussion on overloading [] operator within the C++ Programming forums, part of the General Programming Boards category; I know how to overload the [] operator, but I cant seem to figure out how to to overload it ...

  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,006
    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, 08:05 AM
  2. Need help on understandind arrays
    By C++mastawannabe in forum C++ Programming
    Replies: 9
    Last Post: 06-16-2007, 11:50 PM
  3. Overloading [] operator for a vector
    By nappaji in forum C++ Programming
    Replies: 4
    Last Post: 05-01-2007, 11:44 AM
  4. operator overloading and dynamic memory program
    By jlmac2001 in forum C++ Programming
    Replies: 3
    Last Post: 04-07-2003, 12:51 AM
  5. Overloading the [] operator trouble
    By rmullen3 in forum C++ Programming
    Replies: 2
    Last Post: 08-01-2002, 01:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21