こんなコードが教科書にあり、bo={}の部分でエラーになります。
struct{}に何かが続くような文法がc++にあるのでしょうか・
コード struct bigone{ int serno; char text[1000]; }bo={123,"this is a BIG structure"}; //-- three functions that have the structure as a parameter void valfunc(bigone v1); void ptrfunc(const bigone *p1); void reffunc(const bigone &r1); void main(){ valfunc(bo);//passing the variable itself ptrfunc(&bo);//Passint the address of variable reffunc(bo);//passing a reference to the variable } // pass by value void valfunc(bigone v1){ cout<<'\n'<<v1.serno; cout<<'\n'<<v1.text; } //pass by pointer void ptrfunc(const bigone *p1){ cout<<'\n'<<p1->serno; cout<<'\n'<<p1->text; } //pass by reference void reffunc(const bigone &r1) { cout<<'\n'<<r1.serno; cout<<'\n'<<r1.text; }
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。