If using **GetComponentsByClass **in C++ , Epic wrote following “This intended to only be used by blueprints. Use GetComponents() in C++.”
OLD code
TArray<UActorComponent*> OwnersComponents = ComponentOwner->GetComponentsByClass(UShapeComponent::StaticClass());
NEWCode
TArray<UActorComponent*> OwnersComponents;
ComponentOwner->GetComponents(UShapeComponent::StaticClass(), OwnersComponents,false);