Problem with operator*()

From: Ken Overton (kov_at_nyc.rr.com)
Date: 02/27/05


Date: Sun, 27 Feb 2005 14:34:28 GMT

I have a char-buffer class implementing an operator*() which just returns
the underlying char*. However, when I try to use it I always get this
error:

e:\mine\cbufmsninterop\cmdfactory.cpp(81) : error C2664: 'strcpy' : cannot
convert parameter 2 from 'char' to 'const char *'
        Conversion from integral type to pointer type requires
reinterpret_cast, C-style cast or function-style cast

void dosomething(const CBuffer& param) {
    char buf[MAX_SZ];
    strcpy(fullstr, *param);
    // etc ...
}

The relevant parts of the class are roughly this:

class CBuffer {
 char *buf;
public:
 operator char * () {
  return buf;
 }
} ;

What am I doing wrong, either in the class or in the usage?

-- kov