IDL接口,C ++,CORBA,我处理“为指定的冲突返回类型”和“用于成员函数的无效抽象返回类型”virtual ...“ [英] IDL interface, C++, CORBA, I'm dealing with "conflicting return type specified for" and "invalid abstract return type for member function ‘virtual..."

查看:1344
本文介绍了IDL接口,C ++,CORBA,我处理“为指定的冲突返回类型”和“用于成员函数的无效抽象返回类型”virtual ...“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

3天以上我一直在处理CORBA和C ++以及我在IDL中编写的应用程序界面。

For over 3 days I've been dealing with CORBA and C++ and my app interface written in IDL.

我的应用程序界面如下:

My app interface looks like this:

#ifndef __FORUM_INTERFACE_IDL__
#define __FORUM_INTERFACE_IDL__

#include "Forum.idl"
typedef sequence<Forum> Forums;

interface ForumInterface
{
    Forums getForumList(in Forum f);
    Forums getUsersForumList(in long UsersID);
    void addNewTopic(in Forum f, in long UsersID, in string title);
};

#endif

hh和* .cc文件:omniidl -bcxx ForumInterface.idl

我的论坛对象(也定义在IDL)看起来像:

My Forum-object (also defined in IDL) looks like:

#ifndef __FORUM_IDL__
#define __FORUM_IDL__

interface Forum
{
    long getForumID();
    void setForumID(in long id);
    string getForumName();
    void setFroumName(in string name);
    Forum getForumParent();
    void setForumParent(in Forum f);
};

#endif

hh和* .cc文件:omniidl -bcxx Forum.idl

我试图写一个论坛和ForumInterface的实现。我从Forum开始,下面是类FroumImpl的定义:

I tried to write an implementation of both Forum and ForumInterface. I started with Forum, here's definition of class FroumImpl:

#ifndef __FORUMIMPL_H__
#define __FORUMIMPL_H__

#include "Forum.hh"

class ForumImpl : public POA_Forum
{
    private :

        long id;
        char *name;
        ForumImpl parent;

    public :

        long getForumID();
        void setForumID(long id);
        char* getForumName();
        void setFroumName(const char* name);
        ForumImpl getForumParent();
        void setForumParent(ForumImpl f);
};

#endif

及其声明(现在为空) / p>

and it's declaration (for now it's empty):

#include "ForumImpl.h"

long ForumImpl::getForumID(){}
void ForumImpl::setForumID(long id){}
char* ForumImpl::getForumName(){}
void ForumImpl::setFroumName(const char* name){}
ForumImpl ForumImpl::getForumParent(){}
void ForumImpl::setForumParent(ForumImpl f){}

我尝试编译它,

g++ -c ForumImpl.cpp -I$OMNIORB_HOME/include -I$OMNIORB_HOME/include/omniORB4

但出现错误:


在ForumImpl.cpp中包含的文件中:1:0:ForumImpl.h:12:19:错误:
字段'parent'具有不完整的类型ForumImpl.h:20:19:错误:
为'virtual ForumImpl
指定的冲突返回类型ForumImpl :: getForumParent()'Forum.hh:161:21:error:overriding
'virtual _objref_Forum * _impl_Forum :: getForumParent()'
ForumImpl.h:20:19:error:无效的抽象返回类型为成员
function'virtual ForumImpl ForumImpl :: getForumParent()'
ForumImpl.h:6:7:注意:函数是
纯在'ForumImpl':Forum.hh:162:16:注意:虚拟无效
_impl_Forum :: setForumParent(Forum_ptr)ForumImpl.h:21:14:错误:不能声明参数'f '是抽象类型'ForumImpl'
ForumImpl.h:6:7:注意:因为类型'ForumImpl'有纯虚拟
函数ForumImpl.cpp:在成员函数'virtual ForumImpl
ForumImpl :: getForumParent()':ForumImpl.cpp:7:11:error:invalid
成员函数的抽象返回类型'virtual ForumImpl
ForumImpl :: getForumParent()'ForumImpl.h:6:7 :注意:因为类型
'ForumImpl'有纯虚拟函数ForumImpl.cpp:在全局范围:
ForumImpl.cpp:8:42:错误:不能声明参数'f'为
抽象类型'ForumImpl'ForumImpl.h:6:7:注意:因为类型
'ForumImpl'有纯虚函数

In file included from ForumImpl.cpp:1:0: ForumImpl.h:12:19: error: field ‘parent’ has incomplete type ForumImpl.h:20:19: error: conflicting return type specified for ‘virtual ForumImpl ForumImpl::getForumParent()’ Forum.hh:161:21: error: overriding ‘virtual _objref_Forum* _impl_Forum::getForumParent()’ ForumImpl.h:20:19: error: invalid abstract return type for member function ‘virtual ForumImpl ForumImpl::getForumParent()’ ForumImpl.h:6:7: note: because the following virtual functions are pure within ‘ForumImpl’: Forum.hh:162:16: note: virtual void _impl_Forum::setForumParent(Forum_ptr) ForumImpl.h:21:14: error: cannot declare parameter ‘f’ to be of abstract type ‘ForumImpl’ ForumImpl.h:6:7: note: since type ‘ForumImpl’ has pure virtual functions ForumImpl.cpp: In member function ‘virtual ForumImpl ForumImpl::getForumParent()’: ForumImpl.cpp:7:11: error: invalid abstract return type for member function ‘virtual ForumImpl ForumImpl::getForumParent()’ ForumImpl.h:6:7: note: since type ‘ForumImpl’ has pure virtual functions ForumImpl.cpp: At global scope: ForumImpl.cpp:8:42: error: cannot declare parameter ‘f’ to be of abstract type ‘ForumImpl’ ForumImpl.h:6:7: note: since type ‘ForumImpl’ has pure virtual functions

最糟糕的事情是我不知道为什么这个代码给我这样的错误...我的意思是,我定义所有 ForumImpl 函数...因此任何他们是虚拟现在。我花了几个小时和几个小时试图找出这是什么问题,但没有线索:(

the worst thing is I have no idea why this code gives me such errors ... I mean, I defined all of ForumImpl functions ... so any of them is virtual now. I spent hours and hours trying figure out what's wrong with this but have no clue :(

有人可以帮助吗?我的文件: http://www6.zippyshare.com/v/69552292/file.html 我添加到此tar档案a Makefile,所以简单地运行命令make all,这将做一切

Could anyone help? My files: http://www6.zippyshare.com/v/69552292/file.html I added to this tar archive a Makefile, so simply run command "make all" and this will do everything.

如果有人能告诉我为什么会得到那些错误干脆:)

I would be very grateful if anyone could tell my why I got those error and what to do to fix this, I really need it. Cheers:)

编辑:

我更改了ForumImpl.h和ForumImpl.cpp:

I changed my ForumImpl.h and ForumImpl.cpp:

#ifndef __FORUMIMPL_H__
#define __FORUMIMPL_H__

#include "Forum.hh"

class ForumImpl : public POA_Forum
{
    private :

        long id;
        char *name;
        ForumImpl *parent;

    public :

        long getForumID();
        void setForumID(long id);
        char* getForumName();
        void setFroumName(const char* name);
        ForumImpl* getForumParent();
        void setForumParent(ForumImpl *f);
};

#endif

#include "ForumImpl.h"
long ForumImpl::getForumID(){}
void ForumImpl::setForumID(long id){}
char* ForumImpl::getForumName(){}
void ForumImpl::setFroumName(const char* name){}
ForumImpl* ForumImpl::getForumParent(){}
void ForumImpl::setForumParent(ForumImpl *f){}

但这给了我那些错误:

but this gave me those erros:


g ++ -c ForumImpl.cpp -IMNIORB_HOME / include
-IMNIORB_HOME / include / omniORB4从ForumImpl.cpp中包含的文件: 1:0:ForumImpl.h:20:20:错误:无效的协变返回
'virtual ForumImpl * ForumImpl :: getForumParent()'的类型
Forum.hh:161:21:error:overriding' virtual _objref_Forum *
_impl_Forum :: getForumParent()'

g++ -c ForumImpl.cpp -IMNIORB_HOME/include -IMNIORB_HOME/include/omniORB4 In file included from ForumImpl.cpp:1:0: ForumImpl.h:20:20: error: invalid covariant return type for ‘virtual ForumImpl* ForumImpl::getForumParent()’ Forum.hh:161:21: error: overriding ‘virtual _objref_Forum* _impl_Forum::getForumParent()’


推荐答案

ForumImpl :: getForumParent()应如下所示:

Forum_ptr getForumParent();

有关详细信息,请下载从OMG网站的IDL到C ++映射文档。同时检查Henning& Vinowski的书高级CORBA使用C ++编程

For more information you should download the IDL to C++ mapping document from the OMG website. Also check out Henning & Vinowski's book Advanced CORBA Programming with C++.

这篇关于IDL接口,C ++,CORBA,我处理“为指定的冲突返回类型”和“用于成员函数的无效抽象返回类型”virtual ...“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆