using the scope resolution operator in the below code during the initialization in the constructor gives me error. Why can I only use scope resolution operator in front of the function name (i.e.Vector::Vector(int i)?
class Vector {
public:
Vector(int s); // declaration an interface to definition or what part is.
double& operator[] (int i);
int size();
private:
double* elem;
int sz;
};
Vector::Vector(int s) : Vector::elem{new double[s]},Vector::sz{s} { }
double& Vector::operator[] (int i) { return Vector::elem[i]; }
int Vector::size() { return Vector::sz; }
int main() {
int s = 10;
Vector V(10);
return 0;
}