嘿,所以我正在尝试编译:
//ASSIGNMENT
#include <iostream>
#include <string>
using namespace std;
template <class T>
class Two {
private: T x,y;
public:
Two (T a, T b);
friend void Show (Two p);
~Two();
};
//ASSIGNMENT
template <class T>
Two::Two (T a, T b){
x = a;
y = b;
}
friend void Two::Show(Two p){
cout << p.x << " and " << p.y << endl;
}
int main () {
Two<int> class2(2,3);
Show(class2);
}
任务是定义类的成员(在 //ASSIGNMENT 标记中)。我不知道为什么它不会编译...谢谢!