Re: ? about C++
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, 07 Mar 2002 15:52, a wrote:
> (sorry! if you know any other mailing list i should send, pls tell me)
This is a mailing list on how to use the debian operating system, so it isn't
a particularly good choice. You'd have been better off on a specialist
programming mailing list for, or even debian-devel.
> why the program below is wrong?
>
> class t
> {public :
> static char *p;
> };
> char t::*p;
> main()
> {t k;
> k.p="";
> }
>
Firstly, formatting would make this much easier to read.
class t {
public:
static char *p;
};
char t::*p;
main() {
t k;
k.p="";
}
There is a lot of personal preference involved, but this is much easier to
read than the one you wrote.
Now, the problem is with the line char t::*p
This says to use the default initialiser for the character pointed to by t's
member named p. I'm not sure this is valid even if t::p had been declared,
but it isn't valid if it hasn't.
changing it to
char * t::p should work.
Corrin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6d-cvs (GNU/Linux)
iD8DBQE8huMsi5A0ZsG8x8cRAgAjAJ0TJtBB3vKQW+YQFKXFPrmKlRssugCeL+O+
UqbqZ2by+tlczpPA+8mcMiI=
=5laQ
-----END PGP SIGNATURE-----
Reply to: