-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,466
  • 2
  • 17
  • 29

1 Answers1

2

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

TextBox::Caret TextBox::caret;
piwi
  • 4,928
  • 2
  • 21
  • 45