I know this question has been asked previously; however, I'm not understanding the solutions. I'm trying to create a subclass to std::vector, it's able to inherate member functions (such as push_back
), but not operators (such as =
).
From this example it seems like it should just happen automatically... is the vector class different?
#include <iostream>
#include <vector>
using namespace std;
template <class T>
class FortranArray1 : public std::vector<T> {
public:
T & operator()(int row)
{
return (*this)[row-1];
}
};
int main()
{
vector <double> y;
y = {3}; // works
vector <double> z = y; //works
FortranArray1<double> x;
x = {3}; // doesn't work
x.push_back(3); // works
cout << y[0] << x[0] << ", " << x(1) ;
return 0;
}