remarknibor wrote:
> 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.
vector<string>()
(And you don't need the 'struct' keyword for the initialization.)
However, you really should consider doing something like:
class wordsForSet
{
public:
wordsForSet(setNumInit)
{
setNum = setNumInit;
timeSpent = 0.0;
}
// Consider making these 'private:'.
int setNum;
vector <string> words;
float timeSpent;
};
wordsForSet wordSets[6] = {
wordsForSet(0),
wordsForSet(1),
wordsForSet(2),
wordsForSet(3),
wordsForSet(4),
wordsForSet(5),
};
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/