C++ Class error

Started by
2 comments, last by InFerN0 23 years, 11 months ago
I am getting the message error C2352: ''F_Pak::F_PakClose'' : illegal call of non-static member function when i change it to static F_Pak::F_PakClose it produces errors saying error C2597: illegal reference to data member ''F_Pak::header'' in a static member function what am I doing wrong. I will post full source on request(its not long). Thanks
InFerN0Not all who wander are lost...
Advertisement
The only thing i see is that F_Pak has to be a base class, and you have to be calling it from within a derived class''s member function.

-----------------------------------------------------------
PCMCIA - People Can't Memorize Computer Industry Acronyms
ISDN - It Still Does Nothing
APPLE - Arrogance Produces Profit-Losing Entity
SCSI - System Can't See It
DOS - Defunct Operating System
BASIC - Bill's Attempt to Seize Industry Control
IBM - I Blame Microsoft
DEC - Do Expect Cuts
CD-ROM - Consumer Device, Rendered Obsolete in Months
OS/2 - Obsolete Soon, Too.
WWW - World Wide Wait
MACINTOSH - Most Applications Crash; If Not, The Operating System Hangs
Any time you reference a function like :: the it needs to be in the global scope, hence the "static" modifier. The reason you are getting the second error is that any static function can only access local or static data, it cannot access other members of the class unless they are declared "static" also.

-Liquid
You''re probably calling a non-static member function. That''s illegal, because those accesses require the use of the this pointer, which isn''t present in a static function (since there''s no instance of the class).

So, static member functions can only access other static member functions and member data.

Erik

This topic is closed to new replies.

Advertisement