• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

Conversion

I have class StringWrapper
void StringWrapper::      operator=      (System::String^ Value)
{
    MyString = Value;      
}

Following code:
------------------

StringWrapper a;
a="a";                      // Works well

StringWrapper^ b;
b = "b";                   // does not compile


What I nned to do to get rid of error:
error C2440: '=' : cannot convert from 'const char [2]' to 'StringWrapper ^'
0
PLABB
Asked:
PLABB
1 Solution
 
AlexFMCommented:
   StringWrapper^ b = gcnew StringWrapper();
    *b = "b";

Your code is not compiled because you try to assign string to reference and not to class instance.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now