Как правильно объявить статическую переменную в данном контексте?
#include <iostream>
using namespace std;
struct link
{
int data;
link *next;
};
class some
{
private:
static link *first;
public:
some(int d)
{
link *newlink = new link;
newlink->data = d;
newlink->next = first;
first = newlink;
}
void Show()
{
link *current = first;
while(current)
{
cout << current->data << endl;
current = current->next;
}
}
};
link some::first = nullptr;
int main()
{
some ob1(1), ob2(2), ob3(3);
ob3.Show();
return 0;
}
Ошибки:
conflicting declaration ‘link some::first’ link some::first = nullptr;
previous declaration as ‘link* some::first’ static link *first;
some::first’ outside of class is not definition [-fpermissive] link some::first = nullptr;