![]() |
| | #1 |
| Guest
Posts: n/a
| operator== ----------------------------------------------- Trying to do: if ( iter == My_Rec_List.front() ) ------------------------------------------------ what i have (defined in the struct): friend bool operator==(Record r, const Record &IN2){ return r.First_number == IN2.First_number; } VC++ 6.0 error -------------------- error C2678: binary '==' : no operator defined which takes a left-hand operand of type 'class std::list<struct Record,class std::allocator<struct Record> >::iterator' (or there is no acceptable conversion) Error executing cl.exe. |
|
| | #2 |
| Guest
Posts: n/a
| better yet, writing the record.... what iter x is pointing to is what i need to write... Writes garbage but the only thing i can get to compile Code: SfileS.write((char*)(&x), sizeof(Record)); |
|
| | #3 |
| Sénior Member Join Date: Jan 2002
Posts: 982
| >Trying to do: if ( iter == My_Rec_List.front() ) < You'll have to use the operator* on iter. >what iter x is pointing to is what i need to write...< You could overload operator>> and operator<< to read/write a Records elements to file. |
| Sorensen is offline | |
| | #4 | |
| Guest
Posts: n/a
| Quote:
| |
|
| | #5 |
| Sénior Member Join Date: Jan 2002
Posts: 982
| No if you really need to read/write in binary, then you need to do something like - Code: #include <iostream>
#include <fstream>
using namespace std;
struct TwoInts
{
int a;
int b;
};
int main()
{
ofstream os("ti.bin",ios::binary);
TwoInts one={1,2};
os.write((char *)&one,sizeof(one));
os.close();
ifstream is("ti.bin",ios::binary);
TwoInts two;
is.read((char*)&two,sizeof(two));
cout << two.a << ' ' << two.b << '\n';
return 0;
}
|
| Sorensen is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| operator== | Tux0r | C++ Programming | 17 | 07-09-2009 02:29 AM |
| stl error | eklavya8 | C++ Programming | 8 | 06-30-2008 12:01 PM |
| "error: incomplete type is not allowed" | Fahrenheit | C++ Programming | 9 | 05-10-2005 09:52 PM |
| Problem with Template Function and overloaded equality operator | silk.odyssey | C++ Programming | 7 | 06-08-2004 04:30 AM |