Click here to Skip to main content
14,970,418 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Recieving a Namespace Error on this code....
8 IntelliSense: name followed by '::' must be a class or namespace name

C++
// Fill out your copyright notice in the Description page of Project Settings.


#include "MyPawn.h"

// Sets default values
AMyPawn::AMyPawn()
{
 	// Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
}

// Called when the game starts or when spawned
void AMyPawn::BeginPlay()
{
	Super::BeginPlay();
}

// Called every frame
void AMyPawn::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

// Called to bind functionality to input
void AMyPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);}


What I have tried:

I dont have a clue why is this happening
Posted
Updated 31-Oct-20 22:41pm
v2

I think you want to write __super:: instead of Super.

If you only call the base class with no change to any parameters and do nothing else then it is not necessary to implement the derived method.

-edit-

In lieu of __super, in fact this is what I did before __super existed, you can define a type for the base class. Something like this :
C++
using AMyPawn_Base = PawnBaseClass;
and then you can declare your class like this :
C++
class AMyPawn : public AMyPawn_Base
{
public:
    AMyPawn() : AMyPawn_Base()
    {
    }

    void BeginPlay()
    {
        AMyPawn_Base::BeginPlay();

        // more code here
    }
};
This should work with any c++ compiler that supports using. I would do this because if I ever decided to change the base of a given class it is done in only one place instead of potentially dozens.
   
v5
Comments
Greg Utas 31-Oct-20 15:33pm
   
__super is Microsoft-specific. OP is probably from a Java background, but standard C++ has no "Super", though some people typedef it within a class. If not, you have to name the superclass explicitly, which is also a good idea if using (gag) multiple inheritance.
Stoff Robert 31-Oct-20 16:10pm
   
This is the auto generated code from ue4
Greg Utas 31-Oct-20 16:23pm
   
I have no idea what ue4 is. Like Rick suggested, you should be OK if you use __super. The only drawback is that it's not standard C++.
Rick York 31-Oct-20 17:14pm
   
Visual Studio was noted so I assumed that compiler also.
I suggest you post your question at Unreal Engine[^]. They are much more likely to know what their generated code is supposed to do.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900