I have a very simple demo program that compiles well in Microsoft Visual C ++:
#include <cstdio>
#include <vector>
#include <string>
using namespace std;
class String
:public wstring
{
public:
String(void)
{
}
String(const String &other)
: wstring(other)
{
}
};
int main(void)
{
vector<const String> v;
v.push_back(String());
printf("Hello, World!");
return 0;
}
It creates a vector of constant lines. However, in GNU C ++ 4.8.2, it gives a lot of errors that try to say that it is impossible to create a constant vector of String objects. When I replace vector<const String>with vector<String>, it compiles. What is the reason for this behavior of GNU C ++?
source
share