my problem is with this line:Code:// vectors: overloading operators example #include <iostream> using namespace std; class CVector { public: int x,y; CVector () {}; CVector (int,int); CVector operator + (CVector); }; CVector::CVector (int a, int b) { x = a; y = b; } CVector CVector::operator+ (CVector param) { CVector temp; temp.x = x + param.x; temp.y = y + param.y; return (temp); } int main () { CVector a (3,1); CVector b (1,2); CVector c; c = a + b; cout << c.x << "," << c.y; return 0; }
why does CVector class name have to be written twice otherwise the compiler will report error? In this same code, other class functions has been defined in the global scope, with the class name CVector being written only once. This is where I'm stuck.Code:CVector CVector::operator+ (CVector param) {



LinkBack URL
About LinkBacks



