我有一个函数,我将指针传递给 unsigned char 向量。
有人可以告诉我如何获取函数内的值之一吗?
double CApp::GetCost(unsigned char *uBytes)
{
unsigned char iHP;
iHP=uBytes[49]; //this does not work
}
编辑:对不起,我首先认为我应该简化我的代码,但我认为太多可能会出错。现在这是真正的声明:
// ---------------------------------------
struct ByteFeature
{
unsigned char Features[52];
};
class clsByteFeatures : public CBaseStructure
{
private:
vector<ByteFeature> m_content;
protected:
virtual void ProcessTxtLine(string line);
public:
vector<ByteFeature> &Content();
void Add(ByteFeature &bf);
};
vector<ByteFeature> &clsByteFeatures::Content()
{
return m_content;
}
这就是我使用它的方式:
dblTargetCost = GetCost(m_ByteFeatures.Content()[iUnitID].Features);
另一个问题:像这样简单地传递向量会很糟糕吗?
double CApp::GetCost(vector<unsigned char> &uBytes)
{
//...
}