我目前有一个停电,我是新的c++和CORBA。我试图分配一个CORBA::Char,但是我得到了一个编译器错误“错误:从'CORBA::Char*‘到’CORBA::Char‘的无效转换。有谁知道,我的代码有什么问题,以及如何正确地编写它?
谢谢!西蒙
class Medium_impl : virtual public POA_Media::Medium {
public:
CORBA::Char gettype();
void settype(CORBA::Char);
private:
CORBA::Char type;
};
Medium_impl::Medium_impl (char* _oidstr) {
type='V';
}
void Medium_impl::settype(CORBA::Char _type){
type = _type;
}
CORBA::Char Medium_impl::gettype(){
return type;
}我在测试中得到了错误-Methode ->settype(typei);
void Mediathek_impl::test (void) {
CORBA::Char type[10][1];
strcpy(type[0],"V");
for(int i = 0; i<=9;i++){
char oidstr[20];
sprintf(oidstr,"medium_%d.acc",count);
PortableServer::ObjectId_var tmpoid=PortableServer::string_to_ObjectId(oidstr);
CORBA::Object_var obj = mypoa->create_reference_with_id (tmpoid,"IDL:Medium:1.0");
::Media::Medium_ptr aref = ::Media::Medium::_narrow (obj);
assert (!CORBA::is_nil (aref));
oid[count] = mypoa->reference_to_id(aref);
//here I get the Compiler-error
aref ->settype(type[i]);
count ++;
}发布于 2013-11-24 12:11:55
type已被宣布为:
CORBA::Char type[10][1];然后,type[i]是CORBA::Char*,构建器抱怨不知道如何将其转换为CORBA::Char。我觉得你想:
aref ->settype(type[i][0]);或
CORBA::Char type[10];
strcpy(type,"V");https://stackoverflow.com/questions/20174220
复制相似问题