я получил эту ошибку, и я не в состоянии решить самзапрос элемента, который имеет тип неклассовую
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
код, который дает мне эту ошибку является
Keyword aux();
aux.put_tag(word);
aux.put_site(site);
Я должен отметить, что слово и сайт char *
типа
Теперь мое Ключевое определение класса это один:
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);
}
};
спасибо!
Update
Изменяя
Keyword aux();
aux.put_tag(word);
aux.put_site(site);
в
Keyword aux;
aux.put_tag(word);
aux.put_site(site);
я получил эту ошибку:
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
Подробнее о [наиболее неприятном анализе] (http://en.wikipedia.org/wiki/Most_vexing_parse). –
@JoachimPileborg На самом деле это не то же самое? Ошибка OP была проще, чем в статье, связанной с ней. – john
@john: Действительно. Технически это не MVP, потому что нет никакой двусмысленности. Это просто не может быть истолковано как объявление объекта. –