Re: [Dev-C++] help need for user-conversion operator problem
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2005-08-21 11:52:09
|
Hi!
You have defined a string conversion function that will return
const char*
but you are assigning to a non-const char* variable.
See any problem somewhere ;)
/Per W
On Sun, 21 Aug 2005, bhadram rao wrote:
> Dear friend,
> I'd a problem. I'm using user defined conversion function char* to use like
> char* ch=s1;(string object name); But the problem is that it is giving compilation error. It cannot able to find the conversion operator char*. Can any body solve my problem. Please help me in this aspect.I'd already defined user conversion operator. But still not working.
> String::operator const char*() const
> {
> return buf;
> }
> yours friendly,
> bhadram
> D:\cpppractice\aug20\maincpp.cpp(12) : error C2440: 'initializing' : cannot convert from 'class bhadram::String' to 'char *'
> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
> Error executing cl.exe.
> maincpp.obj - 1 error(s), 0 warning(s)
|