samedi 24 octobre 2020

Expected initializer before subclass method [closed]

I keep getting this error for my subclasses. I've even declared a virtual function in the parent class, but this error persists. Can somebody help?

    In file included from main.cpp:11:0:
MaleAth.h:35:13: error: expected initializer before 'MaleAth'   
 std::string MaleAth::getName()
             ^~~~~~~
In file included from main.cpp:12:0:
FemaleAth.h:40:1: error: expected initializer before 'FemaleAth'
 FemaleAth::getName()
 ^~~~~~~~~
MaleAth.h:35:13: error: expected initializer before 'MaleAth'
 std::string MaleAth::getName()
             ^~~~~~~
FemaleAth.h:40:1: error: expected initializer before 'FemaleAth'
 FemaleAth::getName()
 ^~~~~~~~~

The function is declared in the subclasses as follows:

std::string FemaleAth::getName()
{
    return fName;
}

Aucun commentaire:

Enregistrer un commentaire