operator overloading = and []

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LucW
    New Member
    • Oct 2006
    • 1

    #1

    operator overloading = and []

    I want to overload the []-operator to mimic an array as file access using C++.

    For example:
    Test = MyFile[89];

    To load record 89 into object Test.

    Is this also possible the other way around:

    MyFile[89] = Test;

    That is, to write the contents of Test to record 89 in the file???

    Thank you!!!

    Luc
  • vninja
    New Member
    • Oct 2006
    • 40

    #2
    yup.

    array[2] = object
    makes the value of object stored in mem location of array[2]

    object = array[2]
    makes value of array[2] stored in mem location of object

    Comment

    • dtimes6
      New Member
      • Oct 2006
      • 73

      #3
      What You have To do is:
      Code:
      class FileListClass // MyFlie
      {
          FileClass& operator[](int); //Return Value is Pass By reference !!!
                                                    //Test is FileClass
      };

      Comment

      Working...