1.

Solve : c++ programming:?

Answer»

Hi,

when I compile the code below, I get the following ERROR messages:

[linker error] undefined REFERENCE to `sample_class::UsingFile'
ld returned 1 exit status
[Build Error] ["Class] Error 1



How do I solve this problem? Thanks.



Code: [Select]class sample_class
{

PUBLIC:
sample_class()
{
UsingFile = 0;
}

~sample_class()
{
--UsingFile;
}

static bool IsFileInUse();


private:
static int UsingFile;

};



bool sample_class::IsFileInUse()
{
if(UsingFile != 0)
{
cout &LT;< "File in use" << endl << endl;
return (true);
}

}


int main(int argc, char *argv[])
{


SYSTEM("PAUSE");
return EXIT_SUCCESS;
}



Discussion

No Comment Found