const char ca[]="test"; const char cb[]="test"; const char *pca="test"; //(*) const char *pcb="test"; cout<<(ca==cb)<<endl; //0 cout<<(pca==pcb)<<endl; //1 I'm quite confused about this result.
ca cb are different objects, when dealing with ca==cb, it compares the address of the first elements, so &ca[0]!=&cb[0].
But I don't understand the behaviour of pca pcb.
Does (*) equivalent to
const char temp[]="test"; const char *pca = temp; ?
Is "test" an object? and both pca and pcb points to the first element of this object?
没有评论:
发表评论