473,506 Members | 16,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

compiler error in spite of correct code

Hi all,
if I compile the small example below without defining
"VC6_STUPID_BEHAVIOUR" I get the following compiler error:
error C2614: 'MyCString' : illegal member initialization: 'string' is
not a base or member

can somebody say me why??? In my opinion it should work in both
variants. On Solaris and HP-UX it works fine.

I have to work with MS VC++ 6.0 SP6

best regards
Arno

// vvvvvvvvvvvvvvv snipp vvvvvvvvvvvvvvvv
#include <string>
#include <iostream>

#ifdef VC6_STUPID_BEHAVIOUR
using std::string;
# define std_string string
#else
# define std_string std::string
#endif

class MyCString
: public std_string
{
public:
MyCString(const char *s_);
: std_string(s_)
{
std::cout << "\"" << *this << "\"" <<
std::endl;
};
};

int main (int argc, char *argv[])
{
MyCString s(argv[0]);
return 0;
}
// ^^^^^^^^^^^^ snipp ^^^^^^^^^^^^
Jul 22 '05 #1
6 1761

"arno" <ar***********@sqs.de> wrote in message
news:b1**************************@posting.google.c om...
Hi all,
if I compile the small example below without defining
"VC6_STUPID_BEHAVIOUR" I get the following compiler error:
error C2614: 'MyCString' : illegal member initialization: 'string' is
not a base or member

can somebody say me why??? In my opinion it should work in both
variants. On Solaris and HP-UX it works fine.

I have to work with MS VC++ 6.0 SP6

best regards
Arno


VC++ 6 has many bugs, this is one of them.

john
Jul 22 '05 #2
"arno" <ar***********@sqs.de> wrote in message
news:b1**************************@posting.google.c om...
....
can somebody say me why??? In my opinion it should work in both
variants. On Solaris and HP-UX it works fine.

I have to work with MS VC++ 6.0 SP6 .... class MyCString
: public std_string
{
public:
MyCString(const char *s_);
: std_string(s_)

I guess this is where VC6 chokes on std::string.
Maybe a simple typedef within your class will do as a workaround:
typedef std::string base_string;
MyCString(const char *s_);
: base_string(s_)

This said: you shall not derive from std::string.

Trust me, there always is a better way
(containment or free functions).
regards,
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Jul 22 '05 #3
arno wrote:
Hi all,
if I compile the small example below without defining
"VC6_STUPID_BEHAVIOUR" I get the following compiler error:
error C2614: 'MyCString' : illegal member initialization: 'string' is
not a base or member

can somebody say me why??? In my opinion it should work in both
variants. On Solaris and HP-UX it works fine.

I have to work with MS VC++ 6.0 SP6

best regards
Arno

// vvvvvvvvvvvvvvv snipp vvvvvvvvvvvvvvvv
#include <string>
#include <iostream>

#ifdef VC6_STUPID_BEHAVIOUR
using std::string;
# define std_string string
#else
# define std_string std::string
#endif

class MyCString
: public std_string
{
public:
MyCString(const char *s_);


Is the semilcolon (at the end of the previous line) misplaced?
--
Karthik.
http://akktech.blogspot.com .
Jul 22 '05 #4
:
public:
MyCString(const char *s_);


Is the semilcolon (at the end of the previous line) misplaced?


Yes it is, but this is only a copy/paste error.

arno
Jul 22 '05 #5
> VC++ 6 has many bugs, this is one of them.

hi john,
this means it works how exspected in VC 7.x?

arno
Jul 22 '05 #6

"arno" <ar***********@sqs.de> wrote in message
news:b1**************************@posting.google.c om...
VC++ 6 has many bugs, this is one of them.


hi john,
this means it works how exspected in VC 7.x?


I believe so.

john
Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
2908
by: Neil Zanella | last post by:
Hello, Allow me to share my frustrations with GNU g++. This is the second time something similar happens to me: I can't find anything wrong with my C++ program and yet I get segfaults, and...
102
5571
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler...
16
2828
by: pj | last post by:
(Was originally, probably wrongly, posted to the vc subgroup.) (This doesn't appear to be a c# problem, but a problem with a bug in the Visual Studio c# compiler, but, any help will be welcome...)...
5
1308
by: Sean Wolfe | last post by:
I have a request for the c# compiler one that is an obvious oversight in my opinion. I'm not sure if this is already being implemented in Whidebey, bu i would hope to find it in there, or in the...
10
3246
by: PufferFish | last post by:
Hi folks, I hope that this is the correct group for these things, apologies if not. I've got a strange compiler error. It appears to be similar to the issue described in knowledgebase...
14
2298
by: PengYu.UT | last post by:
Hi, I have the following which has a bug (see the commented line). The one with the bug has the output of 10 -1073752704 The one without the bug has the output of 10
35
3738
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
27
3034
by: Dave | last post by:
I'm having a hard time tying to build gcc 4.3.1 on Solaris using the GNU compilers. I then decided to try to use Sun's compiler. The Sun Studio 12 compiler reports the following code, which is in...
35
2837
by: =?Utf-8?B?UElFQkFMRA==?= | last post by:
I'd really like to be able to constrain a generic type to System.Enum or, better, enum. But of course that results in "Compiler Error CS0702". So far I've been checking the type parameter at...
0
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.