Topic: argument passing


Author: ravis@cbnewsg.cb.att.com (ravi.krishnaswamy)
Date: 22 Jul 93 14:26:18 GMT
Raw View
In section 4.6.3 of Stroustrup's "The C++ programming
Language (2nd edition)", Stroustrup makes the following
statement:

   "A literal, a constant, and an argument that requires
    conversion can be passed as a const& argument, but not
    as a non-const argument."

    Does the following program which compiled fine with
    cfront 2.1 contradict the above statement.



#include<iostream.h>

void dump(int& a, int& b)
{
        b = 12;
        cerr << "a=" << a << ' ' << "b=" << b << '\n';
}



main()
{
        int i = 23;

        dump(i, 33);
}


Paul Mackles




Author: davisonj@bnr.ca (John M Davison)
Date: 22 Jul 1993 23:10:21 GMT
Raw View
In article <CAKLFv.5JC@cbfsb.cb.att.com> ravis@cbnewsg.cb.att.com (ravi.krishnaswamy) writes:
>
>In section 4.6.3 of Stroustrup's "The C++ programming
>Language (2nd edition)", Stroustrup makes the following
>statement:
>
>   "A literal, a constant, and an argument that requires
>    conversion can be passed as a const& argument, but not
>    as a non-const argument."
>
>    Does the following program which compiled fine with
>    cfront 2.1 contradict the above statement.
...
>void dump(int& a, int& b)
...
>        dump(i, 33);

        Yes.
--
John Davison, davisonj@ecn.purdue.edu <---- send followups to THIS ADDRESS!!!!!
(Otherwise your mail will bounce!)  If you work at NT/BNR, please COCOS to
"John Davison".  The information contained in this article isn't necessarily
representative of Northern Telecom or BNR.




Author: raph@panache.demon.co.uk (Raphael Mankin)
Date: Thu, 22 Jul 1993 20:44:48 +0000
Raw View
Yes.
--

Raphael Mankin    Britain and America are two nations
     divided by a common language. -- GBS