=
我在C++中有一个“未明确提及”的问题。
这里,我有:
#include "HelloWorldAgent/helloworldagent.hh"
int main()
{
HelloWorldAgent agent;
agent.run();
}
在另一个C++档案中,下一个编码是:
#ifndef _HELLOWORLDAGENT_HH_
#define _HELLOWORLDAGENT_HH_
#include "../../HumanoidAgent/humanoidagent.hh"
/**
* A friendly robot
*/
class HelloWorldAgent : public bats::HumanoidAgent
{
/**
* Initialize agent
*
* Called a single time when starting up the agent. Put all your initialization stuff
here.
*/
virtual void init();
/**
* Think cycle
*
* Called at each cycle after a message from the server is received and parsed.
Put all your thinking and acting stuff here.
*/
virtual void think();
public:
/**
* The Constructor
*
* Sets this agent s teamname to "Hello". Consider putting initialization stuff in
init() instead of here.
*/
HelloWorldAgent()
: HumanoidAgent(std::string("Hello"))
{
}
};
#endif
我试图将其编成第2版。
g++-I/usr/include/eigen - I /usr/include/sigc++-2.0 - I /usr/lib/sigc++-2.0/include helloworld.cc
给我下一个错误:
In file included from /usr/lib/gcc/i486-slackware-linux/4.5.2/../../../../include/c++/4.5.2/ext/hash_map:60:0,
from HelloWorldAgent/../../HumanoidAgent/../WorldModel/../Hashclasses/hashclasses.hh:25,
from HelloWorldAgent/../../HumanoidAgent/../WorldModel/worldmodel.hh:54,
from HelloWorldAgent/../../HumanoidAgent/humanoidagent.hh:46,
from HelloWorldAgent/helloworldagent.hh:44,
from helloworld.cc:1:
/usr/lib/gcc/i486-slackware-linux/4.5.2/../../../../include/c++/4.5.2/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
/tmp/cc1cjIEs.o: In function main :
helloworld.cc:(.text+0x29): undefined reference to
bats::HumanoidAgent::run()
/tmp/cc1cjIEs.o: In function HelloWorldAgent::HelloWorldAgent() :
helloworld.cc:(.text._ZN15HelloWorldAgentC2Ev[_ZN15HelloWorldAgentC5Ev]+0xfd): undefined reference to
vtable for HelloWorldAgent
/tmp/cc1cjIEs.o: In function HelloWorldAgent::~HelloWorldAgent() :
helloworld.cc:(.text._ZN15HelloWorldAgentD2Ev[_ZN15HelloWorldAgentD5Ev]+0xb): undefined reference to
vtable for HelloWorldAgent
collect2: ld returned 1 exit status
我不知道可以做些什么,也许会说错了。 任何想法?
Thanks in advance. =
PS: No, it is not homework, it is just for fun =