On 2007-09-19 16:12, anon wrote:
> Neelesh Bodas wrote:
>> On Sep 19, 6:15 pm, anon <a...@no.no> wrote:
>>> sachinc.bira...@gmail.com wrote:
>>>> I am pretty new to C++, I have following doubt.
>>>> Why can't we pass an argument to constructor as pointer? As per my
>>>> knowledge referance is like const pointer.
>>>> Any help will be highly appreciated.
>>> You can pass NULL to a pointer. You can not do that to a reference.
>>
>> Incorrect. You can't "pass" anything to a pointer or a reference.
>> entities can be "passed" only to functions. (Perhaps you meant
>> "assign".)
>
> No, I meant pass. As in this example:
>
> void f( const int *p )
> {
> }
> void g( const int &i )
> {
> }
> int main()
> {
> f(NULL);
> g(5);
> }
>
> Maybe I misunderstood OP's question.
No, you are just having some problems with the terminology, in the above
example you pass a NULL pointer to the function f(), you do not pass
NULL to a pointer.
--
Erik Wikström