Geoff Hutchison writes:
 > On Tue, 8 Feb 2000 [EMAIL PROTECTED] wrote:
 > 
 > >  > given that rest is char * and not const char *?  What will (String) =
 > >  > (char *) default to?
 > > 
 > >  No it's not. The opposite would be, barking when (String) = (const char*).
 > 
 > Uhm. I hope I'm not the only one confused by your statement Loic. Are you
 > saying that this code should be OK?

 No, I did not look at it. I was just saying that operator = (const char*)
was good for (char*) assignement. Sorry for the terse response :-} Here is
what I meant:

/*
[loic@localhost tmp]$ g++ -Wall -o /tmp/a /tmp/a.C
/tmp/a.C: In function `int main()':
/tmp/a.C:39: passing `const char *' as argument 1 of `t1::operator =(char *)' discards 
qualifiers
[loic@localhost tmp]$ /tmp/a
t1:char*
t1:char*
t2:const char*
t2:const char*
t3:const char*
t3:char*
[loic@localhost tmp]$ 
*/

#include <iostream.h>

class t1 {
public:
  void operator = (char* foo) { cerr << "t1:char*" << endl; }
};

class t2 {
public:
  void operator = (const char* foo) { cerr << "t2:const char*" << endl; }
};

class t3 {
public:
  void operator = (char* foo) { cerr << "t3:char*" << endl; }
  void operator = (const char* foo) { cerr << "t3:const char*" << endl; }
};

int main()
{
  const char* vconst = "foo";
  char* v = "bar";

  t1 v1;
  v1 = vconst;
  v1 = v;

  t2 v2;
  v2 = vconst;
  v2 = v;

  t3 v3;
  v3 = vconst;
  v3 = v;
}

-- 
                Loic Dachary

                24 av Secretan
                75019 Paris
                Tel: 33 1 42 45 09 16
                e-mail: [EMAIL PROTECTED]
                URL: http://www.senga.org/


------------------------------------
To unsubscribe from the htdig3-dev mailing list, send a message to
[EMAIL PROTECTED] 
You will receive a message to confirm this. 

Reply via email to