[LC++]Copy constructor etc
Fraser Hutchinson
fraser at speakeasy.net
Fri Jul 27 03:58:03 UTC 2001
noisyStringTy &operator = ( const noisyStringTy &ns ) {
if( this != &ns ) {
reinterpret_cast< string &>(*this) =
retinterpret_cast< const noisyStringTy &>(ns);
}
return *this;
}
Should do the trick.
Fraser
> ------------ Original Message -----------
> From: Ram <ram123p at yahoo.com>
> Date: Thu, 26 Jul 2001 01:08:41 -0700 (PDT)
>
>
> --- Mark Phillips <mark at austrics.com.au> wrote:
> > "John F. Dumas" wrote:
>
> > I am trying to do this with the string class but I
> > can't get it working yet. What I have tried is:
> >
> > class noisyStringTy: public string {
> > public:
> > noisyStringTy& operator=(noisyStringTy const& ns)
> > {
> > return string::operator=(ns);
> > cout<<"operator="<<endl;
> > }
> > noisyStringTy(): string() { cout <<
> > "noisyStringTy()" << endl; }
> > noisyStringTy(char const* cStr): string(cStr) {
> > cout<<"noisyStringTy(char const* cStr)"<<endl;
> > }
> > };
> >
>
> I am not sure if we can call a operator = directly as
> above ? I also got the compilation errors.Does anyone
> know how to do the above ?
>
>
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo! Messenger
> http://phonecard.yahoo.com/
> _______________________________________________
> This is the Linux C++ Programming List
> : http://lists.linux.org.au/listinfo/tuxcpprogramming List
More information about the tuxCPProgramming
mailing list