我收到了这个错误,我无法自己解决
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);
我必须提到 word 和 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);
}
};
非常感谢!
更新
通过修改
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