我将自己的类作为参数传递出来有问题。
这是我的代码:
PayloadContainer.h
namespace Project
{
namespace C
{
namespace Helper
{
class PayloadItem
{
public:
string Key;
string Value;
char Type;
char Mode;
char IsArray;
int FieldCount;
char FieldType;
int RowCount;
};
class PayloadContainer
{
public:
PayloadContainer( const char *Command );
PayloadContainer(void);
~PayloadContainer(void);
public:
vector<PayloadItem> PayloadItems;
};
}
}
}
ParseBinary.h
namespace Project
{
namespace C
{
namespace Helper
{
class ParseBinary
{
public:
ParseBinary(void);
~ParseBinary(void);
private:
void WriteRequestToBinary( const char *BinFileName );
void WriteRequestRecord( unsigned char file[], PayloadItem& item, string charSet );
};
}
}
}
ParseBinary.cpp
namespace Project
{
namespace C
{
namespace Helper
{
void ParseBinary::WriteRequestToBinary( const char *BinFileName )
{
unsigned char in;
// Do Something
for (auto &item : _payload->PayloadItems)
{
// Do Something
WriteRequestRecord( in, (Helper::PayloadItem)item, _payload->CharSet );
}
}
void ParseBinary::WriteRequestRecord( unsigned char file[], PayloadItem& item, string charSet )
{
-----> here, I get "error C2511: overloaded member function not found".
}
}
}
}
我想要做的是迭代向量,其中PayloadItem是我自己的类,并将该类传递给函数。
但是,当我构建它时,我得到了这个错误C2511:重载的成员函数未找到错误。
请告诉我在哪里解决此问题。
修改
这是错误消息。
错误9错误C2061:语法错误:标识符'PayloadItem'c:\ webdev \ Project.c.helper \ ParseBinary.h 46 1 Project.C.Helper 错误C2511:在'Project :: C :: Helper :: ParseBinary'中找不到重载的成员函数c:\ webdev \ Project.c.helper \ ParseBinary.cpp 958 1 Project.C.Helper