Declaring TSharedRef in header file will cause "...cannot instantiate abstract class"

I declared

TSharedRef<FInternetAddr>   m_addr;

in my character’s head file.

The compiler always generates errors like:

1>C:\Program Files (x86)\Epic Games\4.11\Engine\Source\Runtime\Core\Public\Templates\SharedPointer.h(176): error C2259: 'FInternetAddr': cannot instantiate abstract class

I also included “Networking.h” in that header file.

Does anyone know what’s wrong?

I think I’ve found the answer. FInternetAddr is an abstract class, so it can’t be declared with TSharedRef.

Use TSharedPtr instead of TSharedRef.

2 Likes