真的想看 C++ 代码?好吧,我相信你看完下面这些之后,想法会有所改变的 
// 以下代码未测试!!懒得找编译器了(因为使用了 TCHAR,不好用 gcc
class Image {
public:
TCHAR* m_name;
TCHAR* m_path;
int m_index;
TCHAR* m_bgm;
Image(TCHAR* name, TCHAR* path, int index) {
m_name = _tcsdup(name);
m_path = _tcsdup(path);
m_index = index;
}
~Image() {
free(m_name);
free(m_path);
}
};
class Character {
public:
POINT m_location;
TCHAR* m_name;
int m_index;
Image** m_cg; // use pointer here
int m_cgLen
Character(POINT location, TCHAR* name, int index, Image** cg, int cgLen) {
m_location = location;
m_name = _tcsdup(name);
m_index = index;
// copy CGs
m_cg = new Image *[cgLen];
m_cgLen = cgLen;
for (int i = 0; i < m_cgLen; i ++) {
Image *c = cg[i];
m_cg[i] = new Image(c->m_name, c->m_path, c->m_index);
}
}
~Character() {
free (m_name);
//
for (int i = 0; i < m_cgLen; i ++) {
delete m_cg[i];
}
}
};
class Selection {
public:
TCHAR* m_context;
int m_index;
int m_jumpSceneIndex;
Selection(TCHAR* context, int index, int jumpSceneIndex) {
m_context = _tcsdup(context);
m_index = index;
m_jumpSceneIndex = jumpSceneIndex;
}
~Selection() {
free(m_context);
}
};
class Word {
public:
int m_type;
Selection** m_selections;
int m_selectionLen;
Word(int type, TCHAR** contextArray, int* indexArray, int* jumpSceneIndexArray, int arrayLen) {
m_selections = new Selection[arrayLen];
m_selectionLen = arrayLen;
for (int i = 0; i < m_selectionLen; i ++) {
m_selections[i] = new Selection(contextArray[i], indexArray[i], jumpSceneIndexArray[i]);
}
}
~Word() {
for (int i = 0; i < m_selectionLen; i ++) {
delete m_selections[i];
}
}
};
class Scene {
public:
TCHAR* m_name;
int m_index;
Image** m_bg;
Character** m_characters;
}; |