Is it legal to compile the attatched code? More specificlly, are the calls
to f() properly resolved? Please explain why in either case.


begin 666 main.zip
M4$L#!!0``@`(`'(-ZS!4`K)IL@```%H"```(````;6%I;BYC<'"]D,T.@C 0
MA,]MTG?8(Q CGLM)PEF?H:W\-(%B^J,'P[N[!4),O(J;7F:FFW[3//_I,,JH
MZH5S4#+Z8O0>9*\59Y0\1GV#)H$4U&B<!]_9\8D2([Q')D:G(F[G>P%5P&'!
M^6+#$YPV+92<-\5B;+Q_`-3&PR"T833!EU 10BYAD+6]-F?;AJ$VWATP4IVP
M64;(9LZLZ5R'5" BNSA&ZK5%M?ZVC%I^)K;VP1HXH9QVJ?4&4$L!`A0`% `"
M``@`<@WK,%0"LFFR````6@(```@``````````0`@( ```````&UA:6XN8W!P
64$L%!@`````!``$`-@```-@`````````
`
end

Re: VC++ standard compliance by Victor

Victor
Sat Jul 10 18:55:45 CDT 2004

"BigMan" <fn42551@fmi.uni-sofia.bg> wrote...
> Is it legal to compile the attatched code? More specificlly, are the calls
> to f() properly resolved? Please explain why in either case.

Sorry, can't receive attachments (are we allowed to post binaries here?)
Perhaps you could simplify your code and copy+paste it into a posting?



Re: VC++ standard compliance by William

William
Sat Jul 10 22:41:22 CDT 2004

"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:uNNDultZEHA.2340@TK2MSFTNGP09.phx.gbl...
> (are we allowed to post binaries here?)

I'm not sure what the policy is but the practice is that they are allowed -
I've posted a few ZIPs here in the past.

Regards,
Will



Re: VC++ standard compliance - code by BigMan

BigMan
Sun Jul 11 01:21:16 CDT 2004

Here's the code and by the way VC++ 7.1 does compile it:

////////////////////////////////////////////////////////////////////////////
///

class B

{

public:

void f( ) const throw( )

{

}

};

////////////////////////////////////////////////////////////////////////////
///

class D : public B

{

public:


using B::f;


void f( )

{

}

};

////////////////////////////////////////////////////////////////////////////
///

int main

(

int NumberOfArguments,

char** Arguments


)

{

D a;

a.f( );


D const b;

b.f( );


return 0;

}

////////////////////////////////////////////////////////////////////////////
///



Re: VC++ standard compliance - code by Sergei

Sergei
Sun Jul 11 03:54:05 CDT 2004

Though the void f() declaration in D hides the f name in B, the
using declaration brings it back to D. So both f functions are
visible and both calls are properly resolved.
Note that exception specification is not considered part of
a functions type and it's the difference in the type of the implicit
object parameter that makes the declarations overloadable.
Declaring the main function parameters in any way other
then (int argc, char *argv[]) invokes undefined behavior
as per clause 999.9.9.9.9 of ISO/IEC 14882:1998(E)

Sergei

"BigMan" <fn42551@fmi.uni-sofia.bg> wrote in message news:ua6Gw9wZEHA.384@TK2MSFTNGP10.phx.gbl...
> Here's the code and by the way VC++ 7.1 does compile it:
>
> ////////////////////////////////////////////////////////////////////////////
> ///
>
> class B
>
> {
>
> public:
>
> void f( ) const throw( )
>
> {
>
> }
>
> };
>
> ////////////////////////////////////////////////////////////////////////////
> ///
>
> class D : public B
>
> {
>
> public:
>
>
> using B::f;
>
>
> void f( )
>
> {
>
> }
>
> };
>
> ////////////////////////////////////////////////////////////////////////////
> ///
>
> int main
>
> (
>
> int NumberOfArguments,
>
> char** Arguments
>
>
> )
>
> {
>
> D a;
>
> a.f( );
>
>
> D const b;
>
> b.f( );
>
>
> return 0;
>
> }
>
> ////////////////////////////////////////////////////////////////////////////
> ///

Re: VC++ standard compliance - code by BigMan

BigMan
Sun Jul 11 09:05:07 CDT 2004

Thanks for the note on main! In fact, I could not find clause 999.9.9.9.9 of
ISO/IEC 14882:1998(E). Did you mean 3.6.1.2?

Now suppose I have 2 versions of a func in the base class: a const one and a
non-const one. They are both private. Are both versions made public in the
derived class if I add a using declaration in the public section of the
derived class? If so, how do I make only one of them public?




"Sergei" <sergei@nospam.summertime.mtu-net.ru> wrote in message
news:eRBCaQyZEHA.2840@TK2MSFTNGP11.phx.gbl...
> Though the void f() declaration in D hides the f name in B, the
> using declaration brings it back to D. So both f functions are
> visible and both calls are properly resolved.
> Note that exception specification is not considered part of
> a functions type and it's the difference in the type of the implicit
> object parameter that makes the declarations overloadable.
> Declaring the main function parameters in any way other
> then (int argc, char *argv[]) invokes undefined behavior
> as per clause 999.9.9.9.9 of ISO/IEC 14882:1998(E)
>
> Sergei
>
> "BigMan" <fn42551@fmi.uni-sofia.bg> wrote in message
news:ua6Gw9wZEHA.384@TK2MSFTNGP10.phx.gbl...
> > Here's the code and by the way VC++ 7.1 does compile it:
> >
> >
////////////////////////////////////////////////////////////////////////////
> > ///
> >
> > class B
> >
> > {
> >
> > public:
> >
> > void f( ) const throw( )
> >
> > {
> >
> > }
> >
> > };
> >
> >
////////////////////////////////////////////////////////////////////////////
> > ///
> >
> > class D : public B
> >
> > {
> >
> > public:
> >
> >
> > using B::f;
> >
> >
> > void f( )
> >
> > {
> >
> > }
> >
> > };
> >
> >
////////////////////////////////////////////////////////////////////////////
> > ///
> >
> > int main
> >
> > (
> >
> > int NumberOfArguments,
> >
> > char** Arguments
> >
> >
> > )
> >
> > {
> >
> > D a;
> >
> > a.f( );
> >
> >
> > D const b;
> >
> > b.f( );
> >
> >
> > return 0;
> >
> > }
> >
> >
////////////////////////////////////////////////////////////////////////////
> > ///



Re: VC++ standard compliance by Tim

Tim
Sun Jul 11 22:30:58 CDT 2004

"BigMan" <fn42551@fmi.uni-sofia.bg> wrote:
>
>Is it legal to compile the attatched code? More specificlly, are the calls
>to f() properly resolved? Please explain why in either case.

Since the code is very short, you should just include it. I have done so,
below.

Did you try this yourself? Inevitably, the best way to answer questions
like this is to just compile it and look at the code.

VC++ compiles this so that the first one calls D::f and the second one
calls B::f. I assume that is what you expected.


///////////////////////////////////////////////////////////////////////////////

class B
{
public:
void f( ) const throw( )
{
}
};

///////////////////////////////////////////////////////////////////////////////

class D : public B
{
public:

using B::f;

void f( )
{
}
};

///////////////////////////////////////////////////////////////////////////////

int main
(
int NumberOfArguments,
char** Arguments

)
{
D a;
a.f( );

D const b;
b.f( );

return 0;
}

///////////////////////////////////////////////////////////////////////////////
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc

Re: VC++ standard compliance - code by Sergei

Sergei
Mon Jul 12 03:00:34 CDT 2004

"BigMan" <fn42551@fmi.uni-sofia.bg> wrote in message news:eT$CEC1ZEHA.2944@TK2MSFTNGP11.phx.gbl...
> Thanks for the note on main! In fact, I could not find clause 999.9.9.9.9 of
> ISO/IEC 14882:1998(E). Did you mean 3.6.1.2?
>
> Now suppose I have 2 versions of a func in the base class: a const one and a
> non-const one. They are both private. Are both versions made public in the
> derived class if I add a using declaration in the public section of the
> derived class?

Yes, both are made public, though in your code the second
would be hidden by D's non-const version.

> If so, how do I make only one of them public?

I do not know any way to do that.

Sergei

> "Sergei" <sergei@nospam.summertime.mtu-net.ru> wrote in message
> news:eRBCaQyZEHA.2840@TK2MSFTNGP11.phx.gbl...
> > Though the void f() declaration in D hides the f name in B, the
> > using declaration brings it back to D. So both f functions are
> > visible and both calls are properly resolved.
> > Note that exception specification is not considered part of
> > a functions type and it's the difference in the type of the implicit
> > object parameter that makes the declarations overloadable.
> > Declaring the main function parameters in any way other
> > then (int argc, char *argv[]) invokes undefined behavior
> > as per clause 999.9.9.9.9 of ISO/IEC 14882:1998(E)
> >
> > Sergei
> >
> > "BigMan" <fn42551@fmi.uni-sofia.bg> wrote in message
> news:ua6Gw9wZEHA.384@TK2MSFTNGP10.phx.gbl...
> > > Here's the code and by the way VC++ 7.1 does compile it:
> > >
> > >
> ////////////////////////////////////////////////////////////////////////////
> > > ///
> > >
> > > class B
> > >
> > > {
> > >
> > > public:
> > >
> > > void f( ) const throw( )
> > >
> > > {
> > >
> > > }
> > >
> > > };
> > >
> > >
> ////////////////////////////////////////////////////////////////////////////
> > > ///
> > >
> > > class D : public B
> > >
> > > {
> > >
> > > public:
> > >
> > >
> > > using B::f;
> > >
> > >
> > > void f( )
> > >
> > > {
> > >
> > > }
> > >
> > > };
> > >
> > >
> ////////////////////////////////////////////////////////////////////////////
> > > ///
> > >
> > > int main
> > >
> > > (
> > >
> > > int NumberOfArguments,
> > >
> > > char** Arguments
> > >
> > >
> > > )
> > >
> > > {
> > >
> > > D a;
> > >
> > > a.f( );
> > >
> > >
> > > D const b;
> > >
> > > b.f( );
> > >
> > >
> > > return 0;
> > >
> > > }
> > >
> > >
> ////////////////////////////////////////////////////////////////////////////

Re: VC++ standard compliance - code by Igor

Igor
Mon Jul 12 12:39:58 CDT 2004

"Sergei" <sergei@nospam.summertime.mtu-net.ru> wrote in message
news:eRBCaQyZEHA.2840@TK2MSFTNGP11.phx.gbl
> Declaring the main function parameters in any way other
> then (int argc, char *argv[]) invokes undefined behavior
> as per clause 999.9.9.9.9 of ISO/IEC 14882:1998(E)

This is not true. C++ standard 3.6.1/2:

It shall have a return type of type int, but otherwise its type is
implementation-defined. All implementations shall allow both of the
following definitions of main:
int main() { /* ... */ }
and
int main(int argc, char* argv[]) { /* ... */ }


--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken