hi
im a little stuck at the moment i wonder if someone can help
in recordtemplate.h i have the following template
template <class RecordType> class RecordClass
{
private:
AnsiString theFileName;
public:
//contructor
RecordClass(){};
//Destructor
~RecordClass(){};
};
in uTenant.h i have the class
//declare the tenant records
class TenantRecord : public RecordClass<AnsiString>
{
private:
public:
char FName[50];
char LName[50];
int Apartment;
};
and in uTenant.cpp :
//create an i/o file
fstream TenantFile;
// create a set of tenant records
set <TenantRecord, less<TenantRecord> > TTenants;
//create and iterator to the set of expense records
set <TenantRecord, less<TenantRecord> >::iterator teniter;
void __fastcall TfrmTenant::btnSaveClick(TObject *Sender)
{
TenantRecord thisrecord;
strcpy(thisrecord.FName,edtFName->Text.c_str());
strcpy(thisrecord.LName, edtLName->Text.c_str());
thisrecord.Apartment = StrToInt(edtApartment->Text);
TTenants.insert(thisrecord);
}
i am getting a compile error on the insert, which seems to be complaining about the "less" in the set.
[C++ Error] function.h(169): E2093 'operator<' not implemented in type 'TenantRecord' for arguments of the same type
what am i doing wrong.. I understand i need to use an iterator but have the same problem when i use it. I am just learning associative containers and templates and am very lost at this point. Pleeeeze help
im a little stuck at the moment i wonder if someone can help
in recordtemplate.h i have the following template
template <class RecordType> class RecordClass
{
private:
AnsiString theFileName;
public:
//contructor
RecordClass(){};
//Destructor
~RecordClass(){};
};
in uTenant.h i have the class
//declare the tenant records
class TenantRecord : public RecordClass<AnsiString>
{
private:
public:
char FName[50];
char LName[50];
int Apartment;
};
and in uTenant.cpp :
//create an i/o file
fstream TenantFile;
// create a set of tenant records
set <TenantRecord, less<TenantRecord> > TTenants;
//create and iterator to the set of expense records
set <TenantRecord, less<TenantRecord> >::iterator teniter;
void __fastcall TfrmTenant::btnSaveClick(TObject *Sender)
{
TenantRecord thisrecord;
strcpy(thisrecord.FName,edtFName->Text.c_str());
strcpy(thisrecord.LName, edtLName->Text.c_str());
thisrecord.Apartment = StrToInt(edtApartment->Text);
TTenants.insert(thisrecord);
}
i am getting a compile error on the insert, which seems to be complaining about the "less" in the set.
[C++ Error] function.h(169): E2093 'operator<' not implemented in type 'TenantRecord' for arguments of the same type
what am i doing wrong.. I understand i need to use an iterator but have the same problem when i use it. I am just learning associative containers and templates and am very lost at this point. Pleeeeze help