Connecting Tech Pros Worldwide Forums | Help | Site Map

private inheritance

Aleksandr Rulev
Guest
 
Posts: n/a
#1: Jul 19 '05
#include <iostream>

class Foo{
public:
Foo(){std::cout<<"Foo ";};
};

class Bar:Foo{
public:
Bar(){std::cout<<"Bar ";};

};

class FooToo: virtual Foo{
public:
FooToo(){std::cout<<"FooToo ";};

};

class FooTooBar: virtual FooToo,virtual Bar{
public:
FooTooBar(){std::cout<<"FooTooBar ";};

};

main (){
FooTooBar x;
}

should x be instantiated o should it give compiler error?



WW
Guest
 
Posts: n/a
#2: Jul 19 '05

re: private inheritance


Aleksandr Rulev wrote:[color=blue]
> #include <iostream>
>
> class Foo{
> public:
> Foo(){std::cout<<"Foo ";};
> };
>
> class Bar:Foo{
> public:
> Bar(){std::cout<<"Bar ";};
>
> };
>
> class FooToo: virtual Foo{
> public:
> FooToo(){std::cout<<"FooToo ";};
>
> };
>
> class FooTooBar: virtual FooToo,virtual Bar{
> public:
> FooTooBar(){std::cout<<"FooTooBar ";};
>
> };
>
> main (){
> FooTooBar x;
> }
>
> should x be instantiated o should it give compiler error?[/color]

Why do you think it should be an error?

--
WW aka Attila


WW
Guest
 
Posts: n/a
#3: Jul 19 '05

re: private inheritance


Aleksandr Rulev wrote:[color=blue]
> main (){[/color]

int main() {

--
WW aka Attila


Aleksandr Rulev
Guest
 
Posts: n/a
#4: Jul 19 '05

re: private inheritance


MS C++ compiles it; Borland doesn't. What is proper behavior? (I don't trust
MS implementation)


"WW" <wolof@freemail.hu> wrote in message
news:bln0pu$d58$1@phys-news1.kolumbus.fi...[color=blue]
> Aleksandr Rulev wrote:[color=green]
> > #include <iostream>
> >
> > class Foo{
> > public:
> > Foo(){std::cout<<"Foo ";};
> > };
> >
> > class Bar:Foo{
> > public:
> > Bar(){std::cout<<"Bar ";};
> >
> > };
> >
> > class FooToo: virtual Foo{
> > public:
> > FooToo(){std::cout<<"FooToo ";};
> >
> > };
> >
> > class FooTooBar: virtual FooToo,virtual Bar{
> > public:
> > FooTooBar(){std::cout<<"FooTooBar ";};
> >
> > };
> >
> > main (){
> > FooTooBar x;
> > }
> >
> > should x be instantiated o should it give compiler error?[/color]
>
> Why do you think it should be an error?
>
> --
> WW aka Attila
>
>[/color]


Aleksandr Rulev
Guest
 
Posts: n/a
#5: Jul 19 '05

re: private inheritance


main() = int main(). you should know.
"WW" <wolof@freemail.hu> wrote in message
news:bln0ql$d7e$1@phys-news1.kolumbus.fi...[color=blue]
> Aleksandr Rulev wrote:[color=green]
> > main (){[/color]
>
> int main() {
>
> --
> WW aka Attila
>
>[/color]


WW
Guest
 
Posts: n/a
#6: Jul 19 '05

re: private inheritance


Aleksandr Rulev wrote:[color=blue]
> MS C++ compiles it; Borland doesn't. What is proper behavior? (I
> don't trust MS implementation)[/color]

Do not top post. What error do you get?

--
WW aka Attila


WW
Guest
 
Posts: n/a
#7: Jul 19 '05

re: private inheritance


Aleksandr Rulev wrote:[color=blue]
> main() = int main(). you should know.[/color]

Nope. You should *not* know. Neither in C++ nor in current C (C99)
implicit int is legal. It has never been part of standard C++.

--
WW aka Attila


Aleksandr Rulev
Guest
 
Posts: n/a
#8: Jul 19 '05

re: private inheritance


Foo()::Foo() is not accessible. // Borland
OK with MS
"WW" <wolof@freemail.hu> wrote in message
news:bln1g5$fck$1@phys-news1.kolumbus.fi...[color=blue]
> Aleksandr Rulev wrote:[color=green]
> > MS C++ compiles it; Borland doesn't. What is proper behavior? (I
> > don't trust MS implementation)[/color]
>
> Do not top post. What error do you get?
>
> --
> WW aka Attila
>
>[/color]


Aleksandr Rulev
Guest
 
Posts: n/a
#9: Jul 19 '05

re: private inheritance



"WW" <wolof@freemail.hu> wrote in message
news:bln1ka$fmk$1@phys-news1.kolumbus.fi...[color=blue]
> Aleksandr Rulev wrote:[color=green]
> > main() = int main(). you should know.[/color]
>
> Nope. You should *not* know. Neither in C++ nor in current C (C99)
> implicit int is legal. It has never been part of standard C++.
>
> --
> WW aka Attila
>
>[/color]

it says that a compiler is not required to
implement
the implicit int rule. That means you cannot rely on this feature in
portable
code.


WW
Guest
 
Posts: n/a
#10: Jul 19 '05

re: private inheritance


Aleksandr Rulev wrote:[color=blue]
> Foo()::Foo() is not accessible. // Borland
> OK with MS[/color]

Do not top post:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.4

--
WW aka Attila


WW
Guest
 
Posts: n/a
#11: Jul 19 '05

re: private inheritance


Aleksandr Rulev wrote:[color=blue]
> it says that a compiler is not required to
> implement the implicit int rule.[/color]

Nope. It does not even mention this rule.
[color=blue]
> That means you cannot rely on this feature in
> portable code.[/color]

http://www.slack.net/~shiva/welcome.txt

--
WW aka Attila


Jonathan Mcdougall
Guest
 
Posts: n/a
#12: Jul 19 '05

re: private inheritance


> > Aleksandr Rulev wrote:[color=blue][color=green][color=darkred]
> > > main() = int main(). you should know.[/color]
> >
> > Nope. You should *not* know. Neither in C++ nor in current C (C99)
> > implicit int is legal. It has never been part of standard C++.
> >
> > --
> > WW aka Attila
> >
> >[/color]
>
> it says that a compiler is not required to
> implement
> the implicit int rule. That means you cannot rely on this feature in
> portable
> code.[/color]

That is the definition of "standard code". Implicit ints are not standard
(not portable) and are implementation-defined.

The thing is, this newsgroup is about Standard C++, not about
implementation-
defined features.


Jonathan


Default User
Guest
 
Posts: n/a
#13: Jul 19 '05

re: private inheritance


Aleksandr Rulev wrote:[color=blue]
>
> main() = int main(). you should know.[/color]


Don't top-post. Your replies belong following properly trimmed quotes.

Your assertion is wrong. In C, before the latest standard, that was
true. It has never been true in standard C++.




Brian Rodenborn
Ralf Schneeweiß
Guest
 
Posts: n/a
#14: Jul 19 '05

re: private inheritance


I think, that your problem is very intresting because of the private virtual
inheritance.
I guess, with the class Bar there is no conflict, because its base class
constructor is
called inside the initialization list implicitly.
With the virtual inheritance you have to repeat an initialization in later
class generations.
The question is now: is the default constructor implicitly reachable from
second and third
class generations or not, if the zero generation is inherited private?

The Comeau compiler gives no error messages.
http://www.comeaucomputing.com/tryitout/

I will look to the standard to find it out.


Ralf



http://www.oop-trainer.de


Jerry Coffin
Guest
 
Posts: n/a
#15: Jul 19 '05

re: private inheritance


In article <B4Efb.169264$3o3.12311887@bgtnsc05-
news.ops.worldnet.att.net>, a.rulev@worldnet.att.net says...

[ ... ]
[color=blue]
> it says that a compiler is not required to
> implement
> the implicit int rule. That means you cannot rely on this feature in
> portable
> code.[/color]

Not so -- what it says is ($7.1.5/2): "At least one type-specifier that
is not a cv-qualifier is required in a declaration unless it declares a
constructor, destructor or conversion function."

That means that any code that tries to use the old implicit int rule
from C is _ill-formed_, which is the terminology the C++ standard uses
signify all those possible input files that aren't C++ programs, so a
properly functioning C++ compiler is required to diagnose them as being
in error.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Closed Thread