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 オブジェクトを 1 つだけインスタンス化する場合は、すべて問題ありません。ただし、次の 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;
}
乾杯、リス