0

how can i do this:


_name__GetAvailable inp;

QString tmp;
inp.From = tmp;

this is definition of name_GetAvailable class:

class SOAP_CMAC _name__GetAvailable
{
public:
    std::string *From;  
    std::string *To;    
    struct soap *soap;  
}

I tried this :

inp.From = tmp.toStdString();

but i've got the following error:

C:\Qt2\Qt5.0.1\Tools\QtCreator\bin\Ticket\mainwindow.cpp:49: error: cannot convert 'std::string {aka std::basic_string}' to 'std::string* {aka std::basic_string*}' in assignment

6
  • 2
    @sashoalm how is that a duplicate? If you read the question you'd see that he'd already converted from QString to std::string. His problem is getting a pointer to a std::string Commented May 16, 2013 at 7:59
  • @sashoalm OP wants a std::string* not just a std::string. Commented May 16, 2013 at 8:00
  • 1
    If you have a std::string, you should be able to come up with a pointer from it, or you should go back to learning C++. Commented May 16, 2013 at 8:01
  • 2
    true. (But that still doesn't make it a duplicate) Commented May 16, 2013 at 8:02
  • The duplicate is for anyone coming from a Google Search. Commented May 16, 2013 at 8:03

1 Answer 1

3

If you want a std::string pointer, you need to allocate a new std::string :

inp.From = new std::string(tmp.toStdString());

But I really don't see the reason why you would need to manipulate std::string by pointer.

If OAP_CMAC _name__GetAvailable is yours, you could manipulate std::string by value :

class SOAP_CMAC _name__GetAvailable
{
public:
    std::string From;  
    std::string To;    
    struct soap *soap;  
}

Otherwise, don't forget to delete the std::string* From and To at some point.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks it worked I used gSOAP toolkit for creating some header and source files and now i'm using its class and functions and i cant change their definitions

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.