Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ undefined symbol
    text
    copied!<p>I am creating a C++ console application where I am saving and loading a vector to a file. The file I am saving and loading has a header that has the size of the vector.</p> <p>Here is my code:</p> <pre><code>void loadFromFile() { ifstream iStream("file.ext", ios::binary); fileHeader_t fHeader; iStream.read((char*)&amp;fHeader, sizeof(fileHeader_t)); if (fHeader.magicNumber = 0xDEADBEAF) { appointments.resize(fHeader.appointmentCount); iStream.read((char*)&amp;appointments[0], fHeader.appointmentCount * sizeof(appointment)); } } void saveToFile() { ofstream oStream("file.ext", ios::binary); fileHeader_t fHeader; fHeader.magicNumber = 0xDEADBEAF; fHeader.appointmentCount = appointments.size(); oStream.write((char*)&amp;fHeader, sizeof(fileHeader_t)); oStream.write((char*)&amp;appointments[0], sizeof(appointment) * appointments.size()); } </code></pre> <p>And here is the header struct:</p> <pre><code>struct fileHeader_s { DWORD magicNumber; size_t appointmentsCount; }fileHeader_t; </code></pre> <p>I am getting the following errors:</p> <blockquote> <p>E2379 Statement missing ; E2451 Undefined symbol 'fHeader'</p> </blockquote> <p>At the following lines:</p> <pre><code>fileHeader_t fHeader; </code></pre> <p>Why is this happening, and more importantly, how can I fix it?</p> <p>Thanks</p> <p><strong>Update</strong></p> <p>Here is my full code:</p> <pre><code>class appointment { public: appointment(string aDate, string aTime, string aType, string aLocation, string aComments, bool aIsImportant, string aReminderDate, string aReminderTime) { appDate = aDate; appTime = aTime; appType = aType; appLocation = aLocation; appComments = aComments; appIsImportant = aIsImportant; appReminderDate = aReminderDate; appReminderTime = aReminderTime; } void setDate(string aDate) { appDate = aDate; } void setTime(string aTime) { appTime = aTime; } void setType(string aType) { appType = aType; } void setLocation(string aLocation) { appLocation = aLocation; } void setComments(string aComments) { appComments = aComments; } void setIsImportant(bool aIsImportant) { appIsImportant = aIsImportant; } void setReminderDate(string aReminderDate) { appReminderDate = aReminderDate; } void setReminderTime(string aReminderTime) { appReminderTime = aReminderTime; } string getDate() { return appDate; } string getTime() { return appTime; } string getType() { return appType; } string getLocation() { return appLocation; } string getComments() { return appComments; } bool getIsImportant() { return appIsImportant; } string getReminderDate() { return appReminderDate; } string getReminderTime() { return appReminderTime; } private: appointment(); string appDate; string appTime; string appType; string appLocation; string appComments; bool appIsImportant; string appReminderDate; string appReminderTime; //person owner; }; class calendar { public: calendar() { loadFromFile(); } ~calendar() { saveToFile(); } void createAppointment(string aDate, string aTime, string aType, string aLocation, string aComments, bool aIsImportant, string aReminderDate, string aReminderTime) { appointment newAppointment(aDate, aTime, aType, aLocation, aComments, aIsImportant, aReminderDate, aReminderTime); appointments.push_back(newAppointment); } private: vector&lt;appointment&gt; appointments; string calCurrentDate; string calCurrentTime; void loadFromFile() { ifstream iStream("file.ext", ios::binary); fileHeader_t fHeader; iStream.read((char*)&amp;fHeader, sizeof(fileHeader_t)); if (fHeader.magicNumber = 0xDEADBEAF) { appointments.resize(fHeader.appointmentCount); iStream.read((char*)&amp;appointments[0], fHeader.appointmentCount * sizeof(appointment)); } } void saveToFile() { ofstream oStream("file.ext", ios::binary); fileHeader_t fHeader; fHeader.magicNumber = 0xDEADBEAF; fHeader.appointmentCount = appointments.size(); oStream.write((char*)&amp;fHeader, sizeof(fileHeader_t)); oStream.write((char*)&amp;appointments[0], sizeof(appointment) * appointments.size()); } typedef struct fileHeader_s { DWORD magicNumber; size_t appointmentCount; }fileHeader_t; }; </code></pre> <p>I am getting the following 2 errors:</p> <p>[BCC32 Warning] Person.cpp(271): W8060 Possibly incorrect assignment Full parser context Person.cpp(245): class calendar Person.cpp(290): decision to instantiate: void calendar::loadFromFile() --- Resetting parser context for instantiation... Person.cpp(267): parsing: void calendar::loadFromFile()</p> <p>[BCC32 Error] vector(608): E2247 'appointment::appointment()' is not accessible Full parser context vector(607): decision to instantiate: void vector >::resize(unsigned int) --- Resetting parser context for instantiation... Person.cpp(18): #include c:\program files (x86)\embarcadero\rad studio\9.0\include\dinkumware\vector vector(8): namespace std vector(330): class vector&lt;_Ty,_Ax> vector(607): parsing: void vector >::resize(unsigned int)</p> <p>Can I please have some help to fix this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload