C ++ Ice Slice将类划分为cpp和h

时间:2018-05-03 21:05:49

标签: c++ slice ice

我是Ice的编程新手,我遇到了问题。我在Ice中编写了模块

module Demo
{
    exception NoSuchWord{};

    sequence<string> words;
    dictionary<string,words> myDictionary;

    interface Translator
    {
        words translate(string s) throws NoSuchWord;
    }
}

在Server.cpp中我实现了接口Translator:

class TranslatorI : public Translator
{
public:
    virtual words translate(const string& s, const Ice::Current&);
};


words TranslatorI::translate(const string& s, const Ice::Current&)
{
    words rewords = dictionary[s];
    if(rewords.size() == 0){
        throw NoSuchWord();
    }
    return rewords;
}

在main(Server.cpp)中创建了InterfaceI:

Ice::ObjectPtr object = new TranslatorI;

如果我在一个类Server.cpp中有类TranslatorIand实现traslator它的工作原理,但当我将它分为Translate.h(类TranslatorI)和Translate.cpp(实现TranslatorI)时,我有问题,如引用vtable TranslatorI

0 个答案:

没有答案