- const int size() { return sz; }
- int size() const { return sz; }
Фрагмент кода №1 приводит к ошибке ff:
E1086:
The object has type qualifiers that are not compatible with the member function Vector::size"
Object Type is: const Vector
Это определение класса Vector:
class Vector {
private:
double* elem;
int sz;
public:
Vector(int s) : elem{ new double }, sz{ s } {}
~Vector() {}
const int size() { return sz; }
//int size() const;
double& operator[](int i);
};
Подробнее здесь: https://stackoverflow.com/questions/797 ... ct-on-code
Мобильная версия