c++ - non-const reference to temporary
- Christof Meerwald <cmeerw web.de> Jan 09 2002
- "Walter" <walter digitalmars.com> Jan 09 2002
Hi,
this one was recently discussed on comp.lang.c++.moderated (a non-const
reference shouldn't be allowed to be bound to a temporary):
#include <stdio.h>
struct A
{ };
int f(const A &a)
{
printf("f(const A &)\n");
return 0;
}
int f(A &a)
{
printf("f(A &)\n");
return 1;
}
int main(int argc, char *argv[])
{
return f(A());
}
But DM calls f(A &) instead of f(const A &).
bye, Christof
Jan 09 2002
Ok, I've got them logged! -Walter "Christof Meerwald" <cmeerw web.de> wrote in message news:a1hu2k$1hkn$2 digitaldaemon.com...Hi, this one was recently discussed on comp.lang.c++.moderated (a non-const reference shouldn't be allowed to be bound to a temporary): #include <stdio.h> struct A { }; int f(const A &a) { printf("f(const A &)\n"); return 0; } int f(A &a) { printf("f(A &)\n"); return 1; } int main(int argc, char *argv[]) { return f(A()); } But DM calls f(A &) instead of f(const A &). bye, Christof
Jan 09 2002








"Walter" <walter digitalmars.com>