Skip to main content
gamedev.net
🔒 Locked

class and statics

Started by kayx_x 1 reply 150+ views
Original Post
kayx_x
kayx_x
#include <iostream.h> class cMyClass { public: static int GetNumber() { return iNumber; } protected: static int iNumber; }; void main() { int iTemp; iTemp = cMyClass::GetNumber(); cout << iTemp; }
felonius
felonius
This is a double post.
Jacob Marner, M.Sc.Console Programmer, Deadline Games
SabreMan
SabreMan

  
#include <iostream>

class cMyClass
{
public:
static int GetNumber() { return iNumber; }
protected:
static int iNumber;
};

int cMyClass::iNumber = 0;

int main()
{
using namespace std;

int iTemp;
iTemp = cMyClass::GetNumber();
cout << iTemp;
}



[ C++ FAQ Lite | ACCU | Boost | Python | Agile Manifesto! ]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.