R
Rob F
I am trying to compile a string class which was working before but
subsequent attempts to make it more 'object orientated' (privatizing
the member variables and implenting query functions) it refuses to
compile in Visual C++.
Here is the code: http://www.rbf.org.uk/xstring.h
When compiling I get the following:
\xstring.h(87) : error C2662: 'query_length' : cannot convert 'this'
pointer from 'const class string' to 'class string &'
Conversion loses qualifiers
\xstring.h(101) : error C2662: 'query_length' : cannot convert 'this'
pointer from 'const class string' to 'class string &'
Conversion loses qualifiers
\xstring.h(114) : error C2662: 'query_length' : cannot convert 'this'
pointer from 'const class string' to 'class string &'
Conversion loses qualifiers
\xstring.h(126) : error C2662: 'query_value' : cannot convert 'this'
pointer from 'const class string' to 'class string &'
Conversion loses qualifiers
\xstring.h(138) : error C2662: 'query_value' : cannot convert 'this'
pointer from 'const class string' to 'class string &'
Conversion loses qualifiers
\xstring.h(153) : error C2662: 'query_length' : cannot convert 'this'
pointer from 'const class string' to 'class string &'
Conversion loses qualifiers
\xstring.h(154) : error C2662: 'query_value' : cannot convert 'this'
pointer from 'const class string' to 'class string &'
Conversion loses qualifiers
and so on and so on...
c:\documents and settings\rob\my documents\my programming
projects\xlibs\xstringtest\xstringtest.cpp(13) : error C2248: '=' :
cannot access private member declared in class 'string'
c:\documents and settings\rob\my documents\my programming
projects\includes\xstring.h(169) : see declaration of '='
What's going on? I can only rectify this problem by making the
variables public and removing the 'const' from the function
parameters. However it should not be trying to modify any of these
variables, so why is it causing errors? It doesn't make any sense to
me...
subsequent attempts to make it more 'object orientated' (privatizing
the member variables and implenting query functions) it refuses to
compile in Visual C++.
Here is the code: http://www.rbf.org.uk/xstring.h
When compiling I get the following:
\xstring.h(87) : error C2662: 'query_length' : cannot convert 'this'
pointer from 'const class string' to 'class string &'
Conversion loses qualifiers
\xstring.h(101) : error C2662: 'query_length' : cannot convert 'this'
pointer from 'const class string' to 'class string &'
Conversion loses qualifiers
\xstring.h(114) : error C2662: 'query_length' : cannot convert 'this'
pointer from 'const class string' to 'class string &'
Conversion loses qualifiers
\xstring.h(126) : error C2662: 'query_value' : cannot convert 'this'
pointer from 'const class string' to 'class string &'
Conversion loses qualifiers
\xstring.h(138) : error C2662: 'query_value' : cannot convert 'this'
pointer from 'const class string' to 'class string &'
Conversion loses qualifiers
\xstring.h(153) : error C2662: 'query_length' : cannot convert 'this'
pointer from 'const class string' to 'class string &'
Conversion loses qualifiers
\xstring.h(154) : error C2662: 'query_value' : cannot convert 'this'
pointer from 'const class string' to 'class string &'
Conversion loses qualifiers
and so on and so on...
c:\documents and settings\rob\my documents\my programming
projects\xlibs\xstringtest\xstringtest.cpp(13) : error C2248: '=' :
cannot access private member declared in class 'string'
c:\documents and settings\rob\my documents\my programming
projects\includes\xstring.h(169) : see declaration of '='
What's going on? I can only rectify this problem by making the
variables public and removing the 'const' from the function
parameters. However it should not be trying to modify any of these
variables, so why is it causing errors? It doesn't make any sense to
me...