Error on const function

Hi.It's my first post in that forum so i hope not to post in wrong thread.Whatever.I have a project for my school and i have the following error on my code.The STORM_FileHandle sfh; is private.I want to use it on that function which is private on my class.REM_RecordFileHandle::ReadRecord(const REM_RecordID& rid,REM_RecordHandle& rh) const;When i use it i have the following error:REM/REM_RecordFileHandle.cpp: In member function 't_rc REM_RecordFileHandle::ReadRecord(const REM_RecordID&, REM_RecordHandle&) const':
REM/REM_RecordFileHandle.cpp:35: error: passing 'const STORM_FileHandle' as 'this' argument of 't_rc STORM_FileHandle::GetPage(int, STORM_PageHandle&)' discards qualifiers


I use the sfh like this:
rc = sfh.GetPage(currentPageID,mph);
where currentPageID is int and mph is STORM_PageHandle object;
rc is a return code class.


Can anyone explain me how could i use the sfh object?Thanks in advance
Non-const member functions (in this case, STORM_FileHandle::GetPage()) can only receive non-const this parameters. Either change the type of the parameter to non-const or change the member function to const.
Last edited on
I don't pass any const parameter on GetPage().GetPage is set as: t_rc STORM_FileHandle::GetPage(int& pageID,STORM_PageHandle& sph);currentPageID is int currentPageID; and mph is STORM_PageHandle mph;.I don't have any const variable to pass it as parameter.And unfortunately i can't change the member function.I am not allowed.
currentPageID is int currentPageID; and mph is STORM_PageHandle mph;
Read what I wrote more carefully.
Non-const member functions can only receive non-const this parameters.

In the call sfh.GetPage(currentPageID,mph), sfh is the implicit this parameter.
Last edited on
You mean to do something like rc = this->sfh.GetPage(currentPageID,mph);
Right?I don't know a lot about const...Sorry.
Topic archived. No new replies allowed.