我想将结构传递给我的函数,但我无法弄清楚。我的代码如下C++将结构传递给函数
struct box
{
char sMaker[40];
float fHeight; //The height of the box
float fWidth; //The width of the box
float fLength; //The length of the box
float fVolume; //The volume of the box
}; //end box
void calcVolume (box *p)
{
p‐>fVolume = p‐>fWidth * p‐>fHeight * p->fLength;
} //end calcVolume
它返回p-是一个未声明的标识符的错误。我真的很陌生,为什么它不编译。
非常感谢。
该代码是正确的AFAICT,虽然你可能想要一个引用,双打和一个'std :: string'。 – chris 2013-02-13 22:54:14
如果这应该是C++ OOP,那么我也会让它成为一个具有返回音量的成员函数的类。我也摆脱了匈牙利的符号。布莱什。 – 2013-02-13 22:55:09