473,386 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

wstring array problem

Hi,

On line nos. 24, 25, 26

24: wstring cfMethods[] = {{L"setLabel"},{L""}};
25: wstring cfProperties[]= {{L"isVisible"},{L""}};
26: wstring cfEvents[] =
{{L"onLoad"},{L"onQueryTerminate"},{L"onTerminate" },{L""}};

i am getting the following errors:

cframe.cpp(24) : error C2552: 'cfMethods' : non-aggregates cannot be
initialized with initializer list
'std::basic_string<_E,_Tr,_A>' : Types with private or
protected data members are not aggregate
with
[
_E=wchar_t,
_Tr=std::char_traits<wchar_t>,
_A=std::allocator<wchar_t>
]
cframe.cpp(24) : error C2552: 'cfMethods' : non-aggregates cannot be
initialized with initializer list
'std::basic_string<_E,_Tr,_A>' : Types with private or
protected data members are not aggregate
with
[
_E=wchar_t,
_Tr=std::char_traits<wchar_t>,
_A=std::allocator<wchar_t>
]
cframe.cpp(25) : error C2552: 'cfProperties' : non-aggregates cannot be
initialized with initializer list
'std::basic_string<_E,_Tr,_A>' : Types with private or
protected data members are not aggregate
with
[
_E=wchar_t,
_Tr=std::char_traits<wchar_t>,
_A=std::allocator<wchar_t>
]
cframe.cpp(25) : error C2552: 'cfProperties' : non-aggregates cannot be
initialized with initializer list
'std::basic_string<_E,_Tr,_A>' : Types with private or
protected data members are not aggregate
with
[
_E=wchar_t,
_Tr=std::char_traits<wchar_t>,
_A=std::allocator<wchar_t>
]
cframe.cpp(26) : error C2552: 'cfEvents' : non-aggregates cannot be
initialized with initializer list
'std::basic_string<_E,_Tr,_A>' : Types with private or
protected data members are not aggregate
with
[
_E=wchar_t,
_Tr=std::char_traits<wchar_t>,
_A=std::allocator<wchar_t>
]
cframe.cpp(26) : error C2552: 'cfEvents' : non-aggregates cannot be
initialized with initializer list
'std::basic_string<_E,_Tr,_A>' : Types with private or
protected data members are not aggregate
with
[
_E=wchar_t,
_Tr=std::char_traits<wchar_t>,
_A=std::allocator<wchar_t>
]
cframe.cpp(26) : error C2552: 'cfEvents' : non-aggregates cannot be
initialized with initializer list
'std::basic_string<_E,_Tr,_A>' : Types with private or
protected data members are not aggregate
with
[
_E=wchar_t,
_Tr=std::char_traits<wchar_t>,
_A=std::allocator<wchar_t>
]
cframe.cpp(26) : error C2552: 'cfEvents' : non-aggregates cannot be
initialized with initializer list
'std::basic_string<_E,_Tr,_A>' : Types with private or
protected data members are not aggregate
with
[
_E=wchar_t,
_Tr=std::char_traits<wchar_t>,
_A=std::allocator<wchar_t>
]

This compiler error is due to the reason:

// initialize a CLR immutable value type that has a constructor
System::DateTime dt = {2001, 4, 12, 22, 16, 49, 844}; // C2552
Question 1. How should i initialize an array of wstring?

Question 2. And what is wrong with the statement below.
wstring cfMethods[] = {{L"setLabel"},{L""}};
Respects,
Saurabh Aggrawal

Jul 22 '05 #1
1 7308
"Saurabh Aggrawal" <ga*****@hotmail.com> wrote in message
news:11********************@c13g2000cwb.googlegrou ps.com...
24: wstring cfMethods[] = {{L"setLabel"},{L""}};
25: wstring cfProperties[]= {{L"isVisible"},{L""}};
26: wstring cfEvents[] =
{{L"onLoad"},{L"onQueryTerminate"},{L"onTerminate" },{L""}};


The error comes from the extra {} around the parameter to
the constructor of individual wstring items -- it is not allowed.

Write the following instead:
wstring cfMethods[] = {L"setLabel",L""};

wstring cfProperties[]= {L"isVisible",L""};

wstring cfEvents[] = {L"onLoad",L"onQueryTerminate",L"onTerminate",L""} ;

hth,

Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com

Jul 22 '05 #2

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

Similar topics

1
by: Vinu | last post by:
Hi I have one problem. I compiled my program with -fshort-wchar option using g++. In my program I am using wstring also. In some places I converted the wchar_t variable to wstring . wstring...
3
by: uday.sen | last post by:
Hi, I am porting a piece of code from VC++ to linux platform. My compiler is g++ 3.2.2. I am getting following error: no matching function for call to A::setResponse(std::wstring) candidates...
8
by: Divick | last post by:
Hi all, can somebody tell how much std::wstring is supported across different compilers on different platforms? AFAIK std::string is supported by almost all C++ compilers and almost all platforms,...
14
by: rohitpatel9999 | last post by:
Hi While developing any software, developer need to think about it's possible enhancement for international usage and considering UNICODE. I have read many nice articles/items in advanced C++...
9
by: Mwob | last post by:
Hi, I have a very simple function, declared like this: wstring CMyClass::GetDate() { .... wcsftime (sDateString,255,L"%d-%b-%Y",&dTmpDate); wstring sText(sDateString); return sText;
1
by: AvinashS | last post by:
I have a WCHAR array (say WCHAR *wszName). I want to convert it to wstring. So, I do the following:- wstring wstrName(wszName); It works. But I want to know what internally happens when the...
10
by: v4vijayakumar | last post by:
1. why the following program is not working as expected? #include <iostream> using namespace std; int main() { string t("test"); wcout << (wchar_t *) t.c_str() << endl; wcout << t.c_str()...
1
by: v4vijayakumar | last post by:
1. Why the following program is not working as expected? #include <iostream> using namespace std; int main() { string t("test"); wcout << (wchar_t *) t.c_str() << endl; wcout << t.c_str()...
6
by: campesr | last post by:
Hi! I'd like to have a map with string keys, and wstring (arrays) values in c++. I thought map<string, wstringwould work out, but it doesn't (at least I think so). Additionally I'd like to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.