Hi guys I'm having a bit of trouble with the following code. What I'm trying to do is initialize static pointer of a class in the same class.
1 2 3 4 5 6 7 8 9 10 11
class SLL
{
private:
SLL *next;
static SLL *FIRST, *LAST;
public:
};
SLL SLL :: FIRST=NULL;
////Both one By one
SLL :: FIRST=NULL;
I've tried "SLL SLL :: FIRST=NULL" and "SLL :: FIRST=NULL" but the program encounters an error stating
"Error 1 error C2040: 'FIRST' : 'SLL' differs in levels of indirection from 'SLL *' c:\users\admin\documents\visual studio 2008\projects\assignment 2\assignment 2\singly.h 39 Assignment 2
"
And
"Error 2 error C2440: 'initializing' : cannot convert from 'int' to 'SLL' c:\users\admin\documents\visual studio 2008\projects\assignment 2\assignment 2\singly.h 39 Assignment 2"
Thanks I've tried it and it almost worked but I'm still facing a problem. It now tells me that I've already defined the static members in the main's obj file.
"Error 1 error LNK2005: "private: static class SLL * SLL::FIRST" (?FIRST@SLL@@0PAV1@A) already defined in 2258-FBAS BSCS4 F11.obj Driver.obj Assignment 2"