What's wrong with this:
struct FileListItem {
string sOriginalFn;
time_t ttTimeTaken;
FileListItem(){}
FileListItem(string _sOriginalFn, time_t _ttTimeTaken) :
sOriginalFn (_sOriginalFn), ttTimeTaken (_ttTimeTaken) { }
};
struct FileList : vector<FileListItem> {
int iCurItm;
FileList() : vector(), iCurItm(-1) {};
void Add(string _sOriginalFn, time_t _ttTimeTaken) {
push_back(FileListItem(_sOriginalFn, _ttTimeTaken));
}
}
I get a run-time "read access violation" the first time Add is called.
I then try:
struct FileList : vector<FileListItem> {
int iCurItm;
FileList() : vector(), iCurItm(-1) {};
FileListItem Itm; // <--- new member
void Add(string _sOriginalFn, time_t _ttTimeTaken) {
Itm(_sOriginalFn, _ttTimeTaken); // <--- E0980 pointing to "Itm"
push_back(Itm);
}
}
and get a compile time error:
E0980 - call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type.
I must have forgotten or missed something since I stopped programming 30 years ago, when Borland C++ was IT...
std::vectorpush_backeven with private inheritance from within you derived class. Note that there is a typo inFileList() : vector(), iCurItm(-1) {};, the semicolon is superfluous at the end.Addwas called. what is your compiler?, iCurItm(-1). and eliminated the superfluous;typo. And still - getting the same runtime error. miradham - can you show the full program you used to test it - maybe it's something about the way I first create or call my objects?