#include<iostream> #include<string> using namespace std; class boy{ private: int age1; string name1; public: boy() { cout<<"please input data girl"<<endl; cin>>age1>>name1; } friend void visitboygirl(boy& a,girl& b); }; class girl{ private: int age; string name; public: girl() { cout<<"please input data girl"<<endl; cin>>age>>name; } friend void visitboygirl(boy& a,girl& b); }; void visitboygirl(boy &a,girl &b) { cout<<"girl:"<<b.age<<" "<<b.name<<endl; cout<<"boy:"<<a.age1<<" "<<a.name1<<endl; } int main() { boy a; girl b; a.visitboygirl(a,b); b.visitboygirl(a,b); return 0; }
总是报错,也不知怎么回事,求解释
朕日理万机