Why can't I call functions on parent classes?

So I have this:

class TWpTaxQueryArray : public TWpNestedQueryArray<UWpTaxQueryEntry> 
{
};

deriving from this:

template<class T>
class WORDPRESSCONTACT_API TWpNestedQueryArray 
{
	//GENERATED_BODY()
	
private:
    TArray<T>* Entries = nullptr;

public:
    TArray<T>* GetEntries()
    {
        return Entries;
    }

    virtual int32 GetEntriesCount() const
    { 
        return Entries  == nullptr ? 0 : Entries->Num(); 
    }

Eventually I get to this:

UCLASS()
class WORDPRESSCONTACT_API UWpTaxQueryEntry : public UCMLData
{
	GENERATED_BODY()	
private:
        TWpTaxQueryArray* QueriesArray = nullptr;

Now comes the problem… When I call QueriesArray->GetEntriesCount() intellisense sees it just fine and it throws me no errors… but when I build I am told that the method is not a part of TWpTaxQueryArray . Okaaayyyyy…

So I got desperate and I tried modifying the class like so:

class TWpTaxQueryArray : public TWpNestedQueryArray<UWpTaxQueryEntry> 
{
public:
    virtual int32 GetEntriesCount() const override
	{
        return Super::GetEntriesCount();
	}
};

but now I am told that

'Super' is not a class or namespace

I don’t get it. I can’t open the project in Unreal because it doesn’t compile and it doesn’t compile because I can’t access parent public methods??? What the…?

Can someone please point out what I am doing wrong?

Since C++ supports multiple inheritance, you cannot have a single “super” class. For UObjects however, multiple inheritance is not allowed outside of interfaces, so technically we know what the “super” class is.

The Super typedef is something generated by UHT for UCLASSes, so your C++ class doesn’t have it, you have to actually type the parent class type when you want to call it
return TWpNestedQueryArray::GetEntriesCount();

Other than that, the code built fine for me, no issues:

template<class T>
class TWpNestedQueryArray
{
private:
	TArray<T>* Entries = nullptr;
public:
	TArray<T>* GetEntries()
	{
		return Entries;
	}

	virtual int GetEntriesCount() const
	{
		return Entries == nullptr ? 0 : Entries->Num();;
	}
};

class TWpTaxQueryArray : public TWpNestedQueryArray<class UTestObject>
{
};

UCLASS()
class UTestObject : public UObject
{
	GENERATED_BODY()

public:
	TWpTaxQueryArray* QueriesArray = nullptr;

	int TestFunction()
	{
		return QueriesArray->GetEntriesCount();
	}
};
1 Like

Thank you.

So the way I understand you is that I can use Super in C++ projects other than in Unreal but for Unreal, best to avoid it unless I want to access my UObject parent. Since everything is most likely going to derive from UObject…

So the fact that my classes don’t actually HAVE a super explains why I get the error when I try to use it. Now the mystery is just “why couldn’t I access my public functions from the inherited class to begin with?” I mean, that was why I got desperate and added the function to access the function of the same name from the parent class.

The only thing I can think of is that I used multiple inheritance on a UObject class and now Uneal doesn’t know which class to get the public function from. Is that actually a thing in Unreal?

So if I want to do multiple inheritance I should rather create an intermediary class that derives from the one class and then the other then the other until I eventually get to the final class I wanted? That doesn’t sound right… is it?