Other compilation error (5)

Hallo everybody) I’ve faced with this problem, and I can’t solve it. This’s PickupItem.h

#pragma once
#include "GameFramework/Actor.h"
#include "PickupItem.generated.h"

UCLASS()
class PROTOTIP1_API APickupItem : public AActor
{
	GENERATED_BODY()
public:
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Item)
		FString Name;
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Item)
		int Quantity;
	
	UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = Item)
		USphereComponent* ProxSphere;

	
	UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = Item)
		UStaticMeshComponent* Mesh;
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Item)
		UTexture2D* Icon;
	
	UFUNCTION(BlueprintNativeEvent, Category = Collision)
	void Prox(class UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
};

This’s PickupItem.cpp


#include "prototip1.h"
#include "PickupItem.h"


APickupItem::APickupItem(const class FObjectInitializer& PCIP) : Super(PCIP)
{
	Name = "UNKNOWN ITEM"; 
	Quantity = 0;
	
	ProxSphere = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("ProxSphere"));
	Mesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Mesh"));
	
	RootComponent = Mesh;
	Mesh->SetSimulatePhysics(true);

	ProxSphere->OnComponentBeginOverlap.AddDynamic(this, &APickupItem::Prox);
	ProxSphere->AttachTo(Mesh);
}
void APickupItem::Prox(class UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
	int a = 2;
}

And here’re errors (from “…Rebuild.bat” prototip1Editor Win64 Development “…\prototip1.uproject” -waitmutex")

[code] …\Source\prototip1\PickupItem.cpp(7): errorC2084: function “APickupItem::APickupItem(const FObjectInitializer &)” already has
the text of the implementation

…\Source\prototip1\PickupItem.cpp(20): warning C4996: ‘USceneComponent::AttachTo’: This function is deprecated, please use AttachToComponent instead. Please update your code to the new API before upgradin
g to the next release, otherwise your project will no longer compile.
[/code]

VS write MSB3073 and other compilation error (5). Thanks in advance

Hi Volkoshkursk,

You arevusing the GENERATE_BODY macro instead of GENERATE_UCLASS_BODY macro in the header file, which doesn’t have that constructor definition.

Also you should probably replace the warning with the other function name specified.

Hope that helps. Cheers,

Thank you, Newest). It’s compiling right now. But how I must edit the code (it was been writed for 4.5.1) for 4.12?

class APickupItem; // forward declare the APickupItem class,
// since it will be "mentioned" in a member function
decl below