what is this error mean 'only a constructor can have a base/member initializer list'

typedef struct xTagItem
      {
      explicit xTAGItem (wchar_t *l) : lpszName(l) {};
      wchar_t *lpszName;
      } xTAGItem;

It try to compile this code,

vector.cpp(13): error C2590: 'xTAGItem' : only a constructor can have a base/member initializer list

Cam anyone know why?
tommym121Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

phoffricCommented:
Not sure, but did you have a typo:
xTagItem
xTAGItem

case-sensitive issue?
0
jkrCommented:
You misspelled it case-wise. You are trying to use a contructor here, but it needs to be exactly like the struct name, i.e.

typedef struct xTagItem // here
      {
      explicit xTagItem (wchar_t *l) : lpszName(l) {}; // here
      wchar_t *lpszName;
      } xTagItem; // and here

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
evilrixSenior Software Engineer (Avast)Commented:
This is C++, you don't need to typedef a struct (or a class) like you do in C. Make your life easier and avoid this nasty and unnecessary syntax.

struct xTagItem
{
   explicit xTagItem (wchar_t *l) : lpszName(l) {};
    wchar_t *lpszName;
};

xTagItem tagItem("some tag");

Open in new window

0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

tommym121Author Commented:
thanks
0
jkrCommented:
Um, shouldn't that have rather been a split? What evilrix wrote is for sure correct, but did not directly address the root of your problem.
0
evilrixSenior Software Engineer (Avast)Commented:
>> did not directly address the root of your problem.
Heh. Well, it does from the point of view that it just circumvents the problem by doing away with the confusing syntax and need to double up on the naming that causes the problem in the first place. That said, earlier posts did identify what the root cause of the actual problem and so, for that reason, I'd be quite happy for this to be reopened with consideration to splitting.

:)
0
jkrCommented:
Thanx! ;o)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.