Can't attach camera to capsule component

is the error same?
also just making sure, did you include both “USceneComponent.h” and “UCapsuleComponent.h”?
another thing to check - it is unlikely to be the cause of the trouble, but can you check if GetCapsuleComponent() is returning a null pointer?