Question

I currently have an blackout and i'm new in c++ and CORBA. I trying to assign an CORBA::Char, but I getting an Compiler-Error "Error: invalid conversion from 'CORBA::Char*' to 'CORBA:Char'. Has anyone an idea, whats wrong with my code and how to write it correct?

Thanks! Simon

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;
}

I get the error in the test-Methode aref ->settype(type[i]);

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 ++; 
}
Was it helpful?

Solution

type has been declared as:

CORBA::Char type[10][1];

then, type[i] is CORBA::Char* and the builder complains about not knowing how to convert it to CORBA::Char. I think that you want:

aref ->settype(type[i][0]);

or

CORBA::Char type[10];

strcpy(type,"V");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top