对 C++ 来说非常新。
这是我的用户定义的 fmiNode 类:(fmi.h)
class fmiNode
{
public:
fmiNode(std::string NodeName,int Address)
{
this->name = NodeName;
this->address = Address;
}
std::string GetName()
{
return this->name;
}
int GetAddress()
{
return this->address;
}
private:
std::string name;
int address;
};
这是我的主要方法(fmi.c)
int main (int argc, char *argv[])
{
fmiNode node1("NodeA",4);
fmiNode node2("NodeB",6);
fmiNode node3("NodeC",8);
fmiNode node4("NodeD",10);
while(1)
{
MainLoop();
}
}
如果我只实例化一个 fmiNode 对象,一切都很好。但以下 3 会导致引发警告:
warning: inlining failed in call to ‘fmiNode::fmiNode(std::string, int)’: call is unlikely and code size would grow [-Winline]
我在这里做错了什么。
编辑:
所以我应该这样定义我的类:?
class fmiNode
{
public:
fmiNode(std::string NodeName,int Address);
std::string GetName()
{
return this->name;
}
int GetAddress()
{
return this->address;
}
private:
std::string name;
int address;
};
fmiNode::fmiNode(std::string NodeName,int Address)
{
this->name = NodeName;
this->address = Address;
}
干杯,里斯