How to use BP defined class in c++ function declaration?

You can’t, blueprint classes are generated at runtime so they are not known at compile time. Use TSubclassOf with the most-derived native parent class instead.

If your BPs extend actor or another very common class, you can make an intermediate c++ class inbetween Actor and the Bp class, just for the sake of filtering.

You can check at runtime if the supplied class is a blueprint class :

if (Cast<UBlueprintGeneratedClass>(In))
{
	// is a blueprint class
}

You can even check if the supplied class is a subclass of a specific blueprint class, but that means hardcoding a string reference which is not recommended :

UClass* BpClassRef = FindObject<UClass>(nullptr, TEXT("/Game/Blueprints/MyBlueprint.MyBlueprint_C"));
if (BpClassRef && In && In->IsChildOf(BpClassRef))
{
	// is a child class of BpClassRef
}