I'm trying to declare a friend function of a class with static members. I compiled my program in Visual Studio 2017 and faced this compile-time error:
unresolved external symbol "private: static struct Number * user::Link" (?Link@user@@0PAUNumber@@A)
Here's my code:
#include<iostream>
using namespace std;
typedef struct Number
{
int number;
struct Number *Link;
}
num_t;
class user
{
private:
static num_t *Link;
static int Length;
public:
static void Create()
{
cout << "You called a function." << endl;
Link->number = 1;
}
friend void Show_menu();
};
void Show_menu()
{
user::Create();
}
int user::Length = 1;
num_t user::*Link = nullptr;
int main()
{
return 0;
}
Generally, Is it possible to define a friend function of a class with static members in C++? If so, how do I fix the problem above?
Aucun commentaire:
Enregistrer un commentaire