问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
friend istream& operator >> (istream& in , PetDog<1,2,3,4,5.>& p){
cout<<"[写入宠物信息]"<<endl;
cout<<"序号:"<<endl;
cin>>p.num;
cout<<"种类:"<<endl;
cin>>p.type;
cout<<"年龄(岁)"<<endl;
cin>>p.age;
cout<<"体重(kg)"<<endl;
cin>>p.weight;
cout<<"状态(1为健康,2为生病):"<<endl;
cin>>p.state;
return in;
}
第二种有错误
friend istream& operator >> (istream& in , PetDog<1,2,3,4,5.>& p){
cout<<"[写入宠物信息]"<<endl;
cout<<"序号:"<<endl;
cin>>p.num;
cout<<"种类:"<<endl;
cin>>p.type;
cout<<"年龄(岁)"<<endl;
cin>>p.age;
cout<<"体重(kg)"<<endl;
cin>>p.weight;
cout<<"状态(1为健康,2为生病):"<<endl;
cin>>p.state;
return in;
运行结果及报错内容
第一种报错
33 45 D:\程序\Devc++\宠物医院管理系统.cpp [Error] 'PetDog' has not been declared
33 51 D:\程序\Devc++\宠物医院管理系统.cpp [Error] expected ',' or '...' before '<' token
第二种报错
36 8 D:\程序\Devc++\宠物医院管理系统.cpp [Error] 'p' was not declared in this scope