I know cpp default class access modifier is private.
What I doubt is generated macro. I can access some functions which are not defined access modifier(so, I thought its private) in AGameMode such as StartMatch(), HasMatchStarted(), etc on its child class by Super keyword.
For example,
class CELLPORTAL_API ACellPortalGameMode : public AGameMode
{
GENERATED_BODY()
virtual void StartMatch();
/* some code */
}
void ACellPortalGameMode::StartMatch()
{
if (!HasMatchStarted())
{
// do something
}
Super::StartMatch();
}
However, I cannot access in below case. In this case, the compiler complaints for access violation error.
class CELLPORTAL_API ACCharacterBase : public ACharacter
{
GENERATED_BODY()
virtual void AccessTest() { /* code */ }
}
class CELLPORTAL_API ACCharacterJoe : public ACCharacterBase
{
GENERATED_BODY()
virtual void AccessTest() override { Super::AccessTest(); }
}
error C2248: ‘ACCharacterBase::AccessTest’ : cannot access private member declared in class ‘ACCharacterBase’
I tried to find what is difference, then I found out AGameMode includes GENERATED_UCLASS_BODY() macro at the first line, but others use GENERATED_BODY(). When I changed GENERATED_BODY() to GENERATED_UCLASS_BODY(), it complied (but occurred some link error for constructors).
So, I guess the auto generated macro would affect default access modifier, but I cannot go further. Does anyone have an idea about it?
Actually, it’s slightly worse than that, as the access is falling through from one class to the next. We’ll definitely get this fixed:
UCLASS()
class UThing1 : public UObject
{
public:
GENERATED_BODY()
void ThisIsPublic();
};
UCLASS()
class UThing2 : public UObject
{
GENERATED_BODY()
void ThisIsAlsoPublic();
private:
void ThisIsPrivate();
};
UCLASS()
class UThing3 : public UObject
{
GENERATED_BODY()
void ThisIsAlsoPrivate();
};
Steve
////
the following is a message from Omnicypher:
speaking of privacy issues, i just gained the power to edit anyone’s posts for some reason… whether its a question or comment, it seems anything on the answerhub has an edit button for me. im not sure who i should report this too, but this is Omnicypher, editing Steve Robbs comment. I hope this isn’t a glitch where everyone can do this… I’m not sure how I should report this in a way that most people wont realize they have the power to edit anything… so i hope this message gets to the right person so this can be fixed.