N
none
This:
#include <vector>
class Image2D {
public:
void test() const {
con.push_back(234);
}
private:
std::vector<int> con;
};
int main(){
Image2D img;
// test();
return 0;
}
compiles fine on ubuntu linux using gcc 4.4.1. But I get an error when I try to compile the same
code in Visual studio 2008. I can fix this error in VS if I declare:
mutable std::vector<int> con;
But why does the gcc compiler not complain when I modify a member in a const function?
#include <vector>
class Image2D {
public:
void test() const {
con.push_back(234);
}
private:
std::vector<int> con;
};
int main(){
Image2D img;
// test();
return 0;
}
compiles fine on ubuntu linux using gcc 4.4.1. But I get an error when I try to compile the same
code in Visual studio 2008. I can fix this error in VS if I declare:
mutable std::vector<int> con;
But why does the gcc compiler not complain when I modify a member in a const function?