user3150552
user3150552

Reputation: 121

expected type-specifier C++ template class

So I am trying to implement a Vector class.

I am getting the error "expected type-specifier before '[' token" in my 'at' function, as shown below:

T Vector<T>::at(unsigned i){
    return operator[i]; 
}

I have tried:

return this->operator[i];

and

(*this).operator[i];

but to no avail. Any ideas?

Upvotes: 3

Views: 144

Answers (1)

Cory Kramer
Cory Kramer

Reputation: 117876

The syntax would be

return this->operator[](i);

or more canonically

return (*this)[i];

Upvotes: 4

Related Questions