|
-
August 15th, 2009, 06:20 AM
#1
const and const_cast issues -please help
I could really use help, please! I'm stuck and frustrated.
I've got:
public const void *myFilePtr
and I need to cast it as a:
int *FilePointer
I've tried using:
int *Filepointer = const_cast<int *>(myFilePointer);
but the class I'm trying to do the cast in is a const class too and I keep getting the error:
passing `const namespace' as `this' argument of `int namespace::myBinarySort(int *filePointer, const string& searchString, int low, int high)' discards qualifiers"
Which I know means I'm still using a const when I shouldn't.
Can someone tell me how to cast this correctly so this const stuff goes away? It's not an option to change what things are marked const sadly.
More Details in case that's not enough:
in program.h
public const void *myFile;
and I have to implement the following class in program.cpp:
bool namespace::getInfo(const string& name, vector<foo>& foo) const
from this class I need to call a binary sort function I wrote as follows:
int namespace::myBinarySort(int *filePointer, const string& searchString, int low, int high)
which I need to return an int pointer to the memory address where searchString is found
And I make the call like this:
int myData = myBinarySearch(mySendingFile, myString, low, high);
So the part I'm having trouble with is correctly casting mySendingFile as int *mySendingFile;
Thanks very much if anyone can help me get unstuck!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|