MFC中的工程编译后出现一个FakeAPP类、属性和输出窗口应该怎么关闭呀?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MFC中的工程编译后出现一个FakeAPP类、属性和输出窗口应该怎么关闭呀?相关的知识,希望对你有一定的参考价值。
参考技术A 因为你建的是visual studio风格的mfc程序,wizard自动帮你填充的追问已经填充了就没办法彻底关闭了吗
CORBA 接口中的属性 - 服务器编译后出现错误
【中文标题】CORBA 接口中的属性 - 服务器编译后出现错误【英文标题】:Attribute in CORBA interface - gave errors after server compilation 【发布时间】:2012-06-25 11:39:08 【问题描述】:我又遇到了 CORBA 的问题。我只是想在 CORBA 中编写一些示例接口,其中接口将具有一个属性。
这是我的 idl 文件:
interface Interfface
readonly attribute double number;
exception myOwnException
string reason;
;
void ffunction(in double arg) raises (myOwnException);
double getNumber();
void setNumber(in double number);
;
我的 IDL 接口实现:
#include "interface.hh"
class Implementation : public POA_Interfface
private :
double number;
public :
virtual void ffunction(double arg);
virtual double getNumber();
virtual void setNumber(double number);
;
#include "implementation.h"
void Implementation::ffunction(double arg)
this->number = 0;
arg++;
throw Interfface::myOwnException("Sth went terribly wrong!");
void Implementation::setNumber(double number)
this->number = number;
double Implementation::getNumber()
return this->number;
当我编译 interface.idl、implementation.h、implementation.cpp 时就可以了。问题是当我想编译我的 server.cpp 时:
#include "implementation.h"
#include <iostream>
#include <omniORB4/CORBA.h>
#include <omniORB4/Naming.hh>
using namespace std;
int main(int argc, char ** argv)
try
// init ORB
CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv);
// init POA
CORBA::Object_var poa_obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(poa_obj);
PortableServer::POAManager_var manager = poa->the_POAManager();
// create service
Implementation * service = new Implementation;
// register within the naming service
try
CORBA::Object_var ns_obj = orb->resolve_initial_references("NameService");
if (!CORBA::is_nil(ns_obj))
CosNaming::NamingContext_ptr nc = CosNaming::NamingContext::_narrow(ns_obj);
CosNaming::Name name;
name.length(1);
name[0].id = CORBA::string_dup("TestServer");
name[0].kind = CORBA::string_dup("");
nc->rebind(name, service->_this());
cout << "Server is running ..." << endl;
catch (CosNaming::NamingContext::NotFound &)
cerr << "not found" << endl;
catch (CosNaming::NamingContext::InvalidName &)
cerr << "invalid name" << endl;
catch (CosNaming::NamingContext::CannotProceed &)
cerr << "cannot proceed" << endl;
// run
manager->activate();
orb->run();
// clean up
delete service;
// quit
orb->destroy();
catch (CORBA::UNKNOWN)
cerr << "unknown exception" << endl;
catch (CORBA::SystemException &)
cerr << "system exception" << endl;
它给了我错误:
server.cpp:在函数'int main(int,char**)'中:server.cpp:20:错误: 无法分配抽象类型“实现”的对象 implementation.h:4: 注意:因为下面的虚函数 在“实施”中是纯的:interface.hh:197:注意:虚拟 CORBA::Double _impl_Interfface::number()
似乎 CORBA 将我的“数字”属性视为函数,而不是属性,对吗?如何解决?
【问题讨论】:
【参考方案1】:通过声明一个属性 number,您将自动获得一个 number() 访问器和设置,您都必须在您的仆人中实现它们。您无需在 IDL 中定义 getNumber() 和 setNumber(),只需从属性中删除 readonly 标记即可拥有 setter。
只需将属性视为自动生成可远程访问的 setter 和 getter 的东西。
【讨论】:
感谢您的回答。我将“数字”定义为只读属性,因为我希望它在我的界面中是私有的(我的界面中的私有字段编号)。是否可以?正如您所写,我删除了“只读”声明,但仍然出现错误:pastie.org/private/ljgn3ekaumcvijj6j3z79w 通过在 IDL 中添加属性可以远程访问。通过删除 readonly 您还必须实现 setter。如果您想让它们完全私有,请从 IDL 中删除属性,然后将它们作为类成员添加到您的实现中。以上是关于MFC中的工程编译后出现一个FakeAPP类、属性和输出窗口应该怎么关闭呀?的主要内容,如果未能解决你的问题,请参考以下文章