ho ottenuto questo errore e non sono in grado di risolvere da solorichiesta di membro che è di tipo non-classe
source.cpp:85:8: error: request for member ‘put_tag’ in ‘aux’, which is of non-class type ‘Keyword()’
source.cpp:86:8: error: request for member ‘put_site’ in ‘aux’, which is of non-class type ‘Keyword()’
make: *** [source.o] Error 1
il codice che mi dà questo errore è
Keyword aux();
aux.put_tag(word);
aux.put_site(site);
devo ricordare che la parola e il sito sono char *
tipo
Ora, la mia definizione di classe di parola chiave è questa:
class Keyword{
private:
std::string tag;
Stack<std::string> weblist;
public:
Keyword();
~Keyword();
void put_tag(std::string word)
{
tag = word;
}
void put_site(std::string site)
{
weblist.push(site);
}
};
Grazie mille!
Aggiornamento
Modificando
Keyword aux();
aux.put_tag(word);
aux.put_site(site);
in
Keyword aux;
aux.put_tag(word);
aux.put_site(site);
ho ottenuto questo errore:
source.o: In function `Algorithm::indexSite(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
source.cpp:(.text+0x2c6): undefined reference to `Keyword::Keyword()'
source.cpp:(.text+0x369): undefined reference to `Keyword::~Keyword()'
source.cpp:(.text+0x4a8): undefined reference to `Keyword::~Keyword()'
source.o: In function `Keyword::put_site(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
source.cpp:(.text._ZN7Keyword8put_siteESs[Keyword::put_site(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)]+0x2a): undefined reference to `Stack<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::push(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: ld returned 1 exit status
make: *** [tema3] Error 1
Leggi [l'analisi più irritante] (http://en.wikipedia.org/wiki/Most_vexing_parse). –
@JoachimPileborg Non è proprio la stessa cosa? L'errore dell'OP era più semplice di quello nell'articolo collegato a. – john
@john: Infatti. Tecnicamente, questo non è MVP, perché non c'è ambiguità. Questo non può essere interpretato come la dichiarazione di un oggetto. –