Ok, I'm experiencing something really weird here.
I'm trying my hands on this ai-tutorial:
http://www.ai-programming.com/bot_tutorial.htm/#intro
I've defined a class called Bot that constitutes the actual AI, and a class called FBot which handles Qt interface stuff. This is the Bot.h file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#ifndef __BOT__
#define __BOT__
#include <QtGui>
typedef struct {
QString input;
QString output;
} knowledge_bit;
class Bot {
public:
Bot(QString n);
~Bot(void);
QString getReply(QString input);
private:
QString name;
knowledge_bit knowledge[2];
};
#endif
|
The knowledge array is being initialized in the Bot constructor like this:
knowledge = {{"Hello", "Hi!"}, {"How are you?", "I'm good, thanks!"}};
(I know, very crude and silly:p)
I've tried various ways of initializing the knowledge array, like outside the class, and in the definition, but none of them have worked. I've also tried making it a pointer instead of an array, to no avail. I'm trying to compile this like it is now, with the length of the array set to 2, and g++ itself segfaults! This the message I got:
Bot.cpp: In constructor ‘Bot::Bot(QString)’:
Bot.cpp:11: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.4/README.Bugs> for instructions.
|
Obviously it is concerning the initialization of the array, but now I've tried everything I can think of. Does anyone know how I can initialize this array? And how did this cause g++ to segfault?
Peace,
Fafner