maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Array of class (https://talk.maemo.org/showthread.php?t=77374)

marmistrz 2011-09-20 16:15

Array of class
 
Hi
I've got a class
Code:

class wbElement
{
public:
    wbElement();
    string name;
    wbState wbs;
};

I'd like to make an array of it. But I don't know how should I define the operator[] function.
Could somebody help?
Thanks in advance
Marcin

TomppaS 2011-09-20 16:54

Re: Array of class
 
Simply:
Code:

wbElement the_array[5];
or with c++ you can use dynamic lists from std. It allows you to remove and add any number of elements in the array.

And remember google is your friend if you got some problem like this :)

marmistrz 2011-09-20 17:09

Re: Array of class
 
it doesn't let me.

/home/marcin/proj/test/main.cpp:79: undefined reference to `wbElement::wbElement()'

marmistrz 2011-09-20 17:18

Re: Array of class
 
Geee! I havn't made the constructor ;)
Now I know why I got that error

daperl 2011-09-20 17:22

Re: Array of class
 
You've declared the constructor, now you have to define it.

Code:

wbElement::wbElement()
{
    ...
}



All times are GMT. The time now is 22:00.

vBulletin® Version 3.8.8