Problem with a pointer to a class pointer
Jul 16, 2012 at 9:19pm UTC
Im getting an "expression must have pointer-to-class type" error in a function where i have a pointer to a class pointer passed in to. Strange thing is if i cast it, it works just fine.
here's the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
ID3v2ReturnCodes GetID3v2Tag(ID3v2Tag** ppTag, char FilePath[MAX_PATH])
{
std::fstream File(FilePath);
if (!File.fail())
{
char Buffer[128];
File.get(Buffer, 4);
if (!strcmp(Buffer, "ID3" ))
{
*ppTag = new ID3v2Tag; // Works fine
File >> dynamic_cast <ID3v2Tag*>(*ppTag)->mMajorVersion; // Works fine
File >> *ppTag->mMajorVersion; // Error
File >> dynamic_cast <ID3v2Tag*>(*ppTag)->mRevisionNumber;
File >> dynamic_cast <ID3v2Tag*>(*ppTag)->mFlags;
dynamic_cast <ID3v2Tag*>(*ppTag)->mSize = File.get() << 21 | File.get() << 14 | File.get() << 7 | File.get();
MessageBox(NULL, "blah" , "debug" , MB_OK);
}
else
return ID3v2RETURNCODE_NOTAGFOUND;
}
else
return ID3v2RETURNCODE_FILEOPENERROR;
}
Any ideas on why this is happening, how to fix it or an other idea on how to do it?
Thanks in advance
Jul 16, 2012 at 9:26pm UTC
*x->y is equivalent to *(x->y). What you meant to write was (*x)->y.
Jul 16, 2012 at 9:28pm UTC
It works :)
thank you very much helios :)
Topic archived. No new replies allowed.