-1

I compile this code:

class TextBox
{
public: 
struct Caret {int x; int y; int index;};
    static Caret caret;
    // more code...
}

and I got this error

error LNK2001: unresolved external symbol "public: static struct TextBox::Caret TextBox::caret" (?caret@TextBox@@2UCaret@1@A)  

What is my mistake

user1544067
  • 1,676
  • 2
  • 19
  • 30

1 Answers1

2

You need to instantiate caret; add this in the source file:

TextBox::Caret TextBox::caret;
piwi
  • 5,136
  • 2
  • 24
  • 48