dhoke
2008-05-27 17:26:23 UTC
Somebody may want to try this with 2007 and see if its accepted, and report
it if:
1)I'm right that it shouldn't be accepted
2) nobody else has reported it
I don't believe the first private constructor prototype should be legal c++
(parameter "const &somecls"). The second/third (commented) prototypes were
what I wanted, but didn't discover the mistake until after the 15-20 minute
build wait (change at low-level header) and subsequent code exercise (to
find it still wasn't working correctly), and then wondering why my "private"
constructor hadn't caused errant code (attempting to pass class
inappropriately by value) to be caught.
(I know there are other situations I've encountered where "int" was
apparently defaulted as return type on methods, and I guess this is probably
another manifestation of that behaviour.)
===========
#include <stdio.h>
class somecls
{
public:
somecls() { } ;
private:
somecls(const &somecls) { } ;
// somecls(const somecls &somecls) { } ;
// somecls(const somecls &) { } ;
} ;
void otherfunc(somecls acls)
{
//compiler doesn't complain about missing type on first private
constructor!!!
printf("Why can't the compiler get it right?\n") ;
}
int main(int argc, char *argv[])
{
somecls acls ;
otherfunc(acls) ;
return 0 ;
}
it if:
1)I'm right that it shouldn't be accepted
2) nobody else has reported it
I don't believe the first private constructor prototype should be legal c++
(parameter "const &somecls"). The second/third (commented) prototypes were
what I wanted, but didn't discover the mistake until after the 15-20 minute
build wait (change at low-level header) and subsequent code exercise (to
find it still wasn't working correctly), and then wondering why my "private"
constructor hadn't caused errant code (attempting to pass class
inappropriately by value) to be caught.
(I know there are other situations I've encountered where "int" was
apparently defaulted as return type on methods, and I guess this is probably
another manifestation of that behaviour.)
===========
#include <stdio.h>
class somecls
{
public:
somecls() { } ;
private:
somecls(const &somecls) { } ;
// somecls(const somecls &somecls) { } ;
// somecls(const somecls &) { } ;
} ;
void otherfunc(somecls acls)
{
//compiler doesn't complain about missing type on first private
constructor!!!
printf("Why can't the compiler get it right?\n") ;
}
int main(int argc, char *argv[])
{
somecls acls ;
otherfunc(acls) ;
return 0 ;
}