1
下面一個例子:http://www.learncpp.com/cpp-tutorial/47-structs/有關結構,當我試圖編譯此程序:C++ - 結構錯誤
#include <iostream>
void PrintInformation(Employee sEmployee)
{
std::cout<<"ID: "<<sEmployee.nID<<std::endl;
std::cout<<"Age: "<<sEmployee.nAge<<std::endl;
std::cout<<"Wage: "<<sEmployee.fWage<<std::endl;
}
struct Employee {int nID;int nAge;float fWage;};
int main()
{
Employee abc;
abc.nID=123;
abc.nAge=27;
abc.fWage=400;
// print abc's information
PrintInformation(abc);
return 0;
}
我得到如下:
爲什麼就是它?
謝謝。
看到這個題目[爲什麼功能需要在使用前需要申報?](http://stackoverflow.com/questions/4757705/why-do-functions-need-to-be-declared-before-they - 使用) – Nawaz 2011-01-22 11:01:14
@Nawaz。感謝您將我引導至頁面。 – Simplicity 2011-01-22 11:26:31