Active Topics

 


Reply
Thread Tools
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#1
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
 
Posts: 37 | Thanked: 191 times | Joined on Nov 2009 @ Finland
#2
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
__________________
My applications:
gTranslate
Battery widget
Guitar Chords
 

The Following User Says Thank You to TomppaS For This Useful Post:
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#3
it doesn't let me.

/home/marcin/proj/test/main.cpp:79: undefined reference to `wbElement::wbElement()'
 
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#4
Geee! I havn't made the constructor
Now I know why I got that error
 
daperl's Avatar
Posts: 2,427 | Thanked: 2,986 times | Joined on Dec 2007
#5
You've declared the constructor, now you have to define it.

Code:
 wbElement::wbElement()
{
    ...
}
__________________
N9: Go white or go home
 

The Following User Says Thank You to daperl For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 12:47.