C++ problem

michael michael8110 at terra.com.br
Thu Aug 5 22:29:03 PDT 2004

hello,i've been quite happily tinkering with C++ for the last few  
months,and i can't remember anything more enjoyable and stimulating in a  
long time,which probably gives away ,well never mind.Problem is as  
follows:i'm trying to build a linked list database,so obviously i'll need  
to put in some text,and that's where things are getting stuck.For  
example,the below code,that would be more or less what i'd do to fill the  
nodes with data,
#include <iostream.h>
class car
char itsName[20];

int main()
{char a[20]="citroen";
car c;
c.itsName=a;  //line 10
return 0;

test.cpp: In function `int main()':
test.cpp:10: error: ISO C++ forbids assignment of arrays (WHY? i'm just  
assigning a pointer here )

test.cpp:10: error: invalid conversion from `const char*' to `char' (CAN'T  
see anything wrong here either,isn't this the usual way of assigning a  
char array?)

compiles and produces the expected
   michael ~ # ./a.out

Would someone be so kind as to shed some light on this confusing state of  
affairs?I mean,if it's ok to assign "citroen" to a[20] ,why not then also  
to c.itsName[20] ?Thank you!
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/

More information about the lfs-chat mailing list