Thread: File handling with Array filled with a class

  1. #16
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> Would appreciate any help.

    I think it would be best to start a separate thread and post your code and the exact error message. These types of errors can have many different causes.

  2. #17
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Persoanlly, I woudl just treat the class as if it were a struct. The member functions are only contextual, they dont actually occupy space in the object. You may want to use #pragma pack(1) to guarantee the smallest footprint

  3. #18
    Registered User
    Join Date
    Jun 2008
    Posts
    2
    I declare it in my class and when I wnat to use the function as below I get the error message No match for operator[]. If I remove the line dayReport[i].dayOfMonth = dayP then it works but it is not read into the array.

    Code:
    istream& operator >> (istream& fin, weatherReport dayReport[])
    {
        Do something
        dayReport[i].dayOfMonth = dayP;
    }

  4. #19
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    I think you should be reading into a weatherReport & instead of into the array. That's just how it's done in C++. Move the code that loops through the array into a separate function and read into each weatherReport one at a time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File being filled with NULLs
    By Tigers! in forum Windows Programming
    Replies: 2
    Last Post: 06-30-2009, 05:28 PM
  2. #include header files or .cpp files?
    By DoctorX in forum C++ Programming
    Replies: 3
    Last Post: 12-23-2006, 12:21 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM