0
\$\begingroup\$

I get the following error:

  [...]\ClassB.cpp:7: erreur : C2248: 'UClassA::UClassA' : cannot access private member declared in class 'UClassA'
  [...]\ClassA.h:12: see declaration of 'AClassA::AClassA'
  [...]\ClassA.h:9: see declaration of 'AClassA'

when I create a subsubclass.

The problem occurs with the following code:

ClassA.h

#pragma once

#include "GameFramework/Actor.h"
#include "ClassA.generated.h"

UCLASS()
class PROBUILDER_API AClassA : public AActor
{
    GENERATED_BODY()
    AClassA( const FObjectInitializer& ObjectInitializer );

};

ClassA.cpp

#include "ProBuilder.h"
#include "ClassA.h"

AClassA::AClassA(const FObjectInitializer &ObjectInitializer):Super(ObjectInitializer)
{

}

ClassB.h

#pragma once

#include "ClassA.h"
#include "ClassB.generated.h"

UCLASS()
class PROBUILDER_API AClassB : public AClassA
{
    GENERATED_BODY()
    AClassB( const FObjectInitializer& ObjectInitializer );

};

ClassB.cpp

#include "ProBuilder.h"
#include "ClassB.h"


AClassB::AClassB(const FObjectInitializer &ObjectInitializer):Super(ObjectInitializer)
{

}

(I tried with a subclass of AActor and UMeshComponent and got the same errors)

\$\endgroup\$
  • 2
    \$\begingroup\$ Well yeah, you can't access private members from any other class (except friends). That's what private means. \$\endgroup\$ – user253751 Sep 17 '15 at 11:30
0
\$\begingroup\$

I just forgot to set my constructor to public.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.