调用子类的子例程后指针消失
Pointers disappear after calling sub-routine of child class
我试图做一个类的一些功能,将与其他(继承)共同出现。这是我的主要类:
class SREngineJulius_father {
protected:
bool g2pInit;
Recog *recog;
Jconf *jconf;
public:
bool InitG2P(std::string dic, std::string model, int pos_process_flag=-1);
bool Init_AM(std::string configStr);
};
两个函数InitG2P
和Init_AM
,将在recog
和jconf
中更新。这个更新是子类的所有子对象都必须拥有的。
class SREngineJulius: public SREngineJulius_father
{
DFA_INFO *dfaInfo;
WORD_INFO *wordInfo;
WORD_INFO *wordInfo_init;
Output lastResult;
TListString lastCmdList;
bool startNotifyCallbackLoop;
bool terminate;
bool pause;
DFA_INFO* copy_dfa_info(DFA_INFO* dfa);
DFA_INFO* create_commands_dfa_info();
static void status_recready(Recog *recog, void *dummy);
static void status_recstart(Recog *recog, void *dummy);
static void output_result(Recog *recog, void *dummy);
static void put_hypo_phoneme(WORD_ID *seq, int n, WORD_INFO *winfo);
std::string ReplaceSpace(std::string &str);
std::string RestoreSpace(std::string &str);
public:
bool InitG2P(std::string dic, std::string model, int pos_process_flag=-1);
char* NotifyCallbackLoop(char *ficheiro_wav);//AXY5
int SREngineJulius::Audio_Buffering(char* buffer_audio, int sizefile, int end_flag_, int flag_alocation);//AXY5
void Callbacks();
public:
~SREngineJulius();
bool InitSREngine(std::string recoConfig);
bool DynamicAddCommands(TListString &cmdlist, int startRecog = -1);
bool DynamicAddCommands(std::string cmdlist, std::string sep=" ", int startRecog = -1);
void Release();
};
所以问题是,当我调用子类的例程时,recog
和jconf
被删除。
您应该在您的类中创建可以修改这两个变量的函数。尝试将它们插入到匿名结构中。这样它们就很容易被访问。
记住:。=参考指针-> =
最后,您在几个函数声明中更改了识别。尽量确保你所创建的函数是友好的。否则,您将无法使用它们。
注。子类的子类,它们需要访问器函数。它们必须通过向上继承来改变指针。所以你会想让祖父类的子类有一个类来改变它的指针。你可以用一个函数来访问子节点,在孙子节点中。这样你就回到了函数里。这就是它们之间的关系
相关文章:
- 1d 智能指针不适用于语法 (*)++
- 在C#中处理C++指针而不使用unsafe的最佳方法
- 为什么使用 "this" 指针调用派生成员函数?
- 函数向量_指针有不同的原型,我可以构建一个吗
- 使用指针从C++中的数组中获取最大值
- 助记符和指向成员语法的指针
- 嵌入方指针压缩已禁用
- 数组的指针从不分段故障
- C++ 指针的内存地址和指向数组的内存地址如何相同?
- 何时在引用或唯一指针上使用移动语义
- QMetaObject invokeMethod的基于函数指针的语法
- 如何从 std::atomic 中提取指针 T<T>?
- 将地址分配给本地指针后,公共对象的变量将消失
- 应用地址清理器后,免费无效指针消失
- 返回的指针属性中类实例上的矢量属性消失
- 如何将指针分配给功能中的新对象,而不会使该对象在退出后消失
- 添加printf语句时,NULL指针异常消失
- 当我使用函数指针时,变量会消失
- 调用子类的子例程后指针消失
- 我好像有消失的指针