more C++ (previously sent without a title,sorry)

michael michael8110 at terra.com.br
Tue Aug 10 23:43:16 PDT 2004


From: michael <michael8110 at terra.com.br>

Glad to see you are making heads and tails of all this!!  It's very nice
to see someone so dedicated to learning a language, and doing it by
testing and discussion.
It is likewise very nice to get so much support from all of you,thanks  
very much again!
Sooo,finally you've admitted it!
  " For char pointers, which
ar[3] ends up being, the language itself knows to actually output the
string it points to."
So the simple question remains(and that,Björn,is the point)
why does g++ applied to the following
#include<iostream>
using namespace std;
class car
{public:
char itsName[20];
car(char a[20]){itsName=a;}
};
int main()
{car c("citroen");
cout<<c.itsName;
return 0;
}

return
test7.cpp: In constructor `car::car(char*)':
test7.cpp:6: error: incompatible types in assignment of `char*' to  
`char[20]'
after all doesn't "the language know" that when it sees a char* it's the  
string the poor devil means?I mean,if i do
char a[20]="citroen";
cout<<a;
i'll get the string as seen above...so why can't the constructor (car(char  
a[20]){itsName=a;} )do the same,since it
already admits itsName by itself stands for a char[20]?Either both a and  
itsName are char* or char[20].Oh,my
god...I'm currently reading a novel written in 1920 that's written in  
beautiful english ,and i guess some of it
would express the general feeling here :' a cessation of proceedings on  
this matter would probably be in order'

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/



More information about the lfs-chat mailing list