If I use a vector instead of an array to hold my strings (which I
like the idea of because then I don't have to specify the size in
advance), I still don't know how to declare an empty one in the
wordSets:
struct wordsForSet {
int setNum;
vector <string> words;
float timeSpent;
};
struct wordsForSet wordSets[6] = {
{0, "", 0},
{1, "", 0},
{2, "", 0},
{3, "", 0},
{4, "", 0},
{5, "", 0}
};
What do I write instead of "" in the struct?
(I am using the default compiler for Visual C++ 2005 Express Edition.)
Thanks,
Robin.
--- In [email protected], Thomas Hruska <[EMAIL PROTECTED]> wrote:
>
> remarknibor wrote:
> > I'm trying to create a structure that holds a number of word
sets.
> > Each word set consists of the number of the set, a list of words
in
> > the set, and the time a participant spends on the set:
> >
> > struct wordsForSet {
> > int setNum;
> > string words[50];
> > float timeSpent;
> > };
> >
> > struct wordsForSet wordSets[6] = {
> > {0, "", 0.0},
> > {1, "", 0.0},
> > {2, "", 0.0},
> > {3, "", 0.0},
> > {4, "", 0.0},
> > {5, "", 0.0}
> > };
> >
> > This code compiled in Dev-C++, but I'm now moving to Visual C++
and
> > it's found errors with the code:
> >
> > "error C2440: 'initializing' : cannot convert from 'double'
> > to 'std::string' 1> No constructor could take the source type, or
> > constructor overload resolution was ambiguous"
> >
> > I guess it's something to do with initialising the string arrays,
but
> > I don't know how to fix it.
> >
> > Any suggestions would be much appreciated.
> >
> > Thanks,
> >
> > Robin.
>
> The compiler is complaining about the initialization of the second
> parameter (apparently expecting all 50 entries to be filled in).
What
> VC++ compiler are you using?
>
> Consider using vector<> (or Block<>) instead of declaring
50 'string's.
> Also, the code seems poorly designed (you are using C++ templates
but
> not classes to encapsulate functionality).
>
> --
> Thomas Hruska
> CubicleSoft President
> Ph: 517-803-4197
>
> *NEW* MyTaskFocus 1.1
> Get on task. Stay on task.
>
> http://www.CubicleSoft.com/MyTaskFocus/
>