473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

private inheritance

#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?
Jul 19 '05 #1
14 5666
WW
Aleksandr Rulev wrote:
#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?


Why do you think it should be an error?

--
WW aka Attila
Jul 19 '05 #2
WW
Aleksandr Rulev wrote:
main (){


int main() {

--
WW aka Attila
Jul 19 '05 #3
MS C++ compiles it; Borland doesn't. What is proper behavior? (I don't trust
MS implementation)
"WW" <wo***@freemail.hu> wrote in message
news:bl**********@phys-news1.kolumbus.fi...
Aleksandr Rulev wrote:
#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?


Why do you think it should be an error?

--
WW aka Attila

Jul 19 '05 #4
main() = int main(). you should know.
"WW" <wo***@freemail.hu> wrote in message
news:bl**********@phys-news1.kolumbus.fi...
Aleksandr Rulev wrote:
main (){


int main() {

--
WW aka Attila

Jul 19 '05 #5
WW
Aleksandr Rulev wrote:
MS C++ compiles it; Borland doesn't. What is proper behavior? (I
don't trust MS implementation)


Do not top post. What error do you get?

--
WW aka Attila
Jul 19 '05 #6
WW
Aleksandr Rulev wrote:
main() = int main(). you should know.


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
Jul 19 '05 #7
Foo()::Foo() is not accessible. // Borland
OK with MS
"WW" <wo***@freemail.hu> wrote in message
news:bl**********@phys-news1.kolumbus.fi...
Aleksandr Rulev wrote:
MS C++ compiles it; Borland doesn't. What is proper behavior? (I
don't trust MS implementation)


Do not top post. What error do you get?

--
WW aka Attila

Jul 19 '05 #8

"WW" <wo***@freemail.hu> wrote in message
news:bl**********@phys-news1.kolumbus.fi...
Aleksandr Rulev wrote:
main() = int main(). you should know.


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


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.
Jul 19 '05 #9
WW
Aleksandr Rulev wrote:
Foo()::Foo() is not accessible. // Borland
OK with MS


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

--
WW aka Attila
Jul 19 '05 #10
WW
Aleksandr Rulev wrote:
it says that a compiler is not required to
implement the implicit int rule.
Nope. It does not even mention this rule.
That means you cannot rely on this feature in
portable code.


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

--
WW aka Attila
Jul 19 '05 #11
> > Aleksandr Rulev wrote:
main() = int main(). you should know.


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


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.


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
Jul 19 '05 #12
Aleksandr Rulev wrote:

main() = int main(). you should know.

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
Jul 19 '05 #13
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
Jul 19 '05 #14
In article <B4Efb.169264$3o3.12311887@bgtnsc05-
news.ops.worldnet.att.net>, a.*****@worldnet.att.net says...

[ ... ]
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.


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.
Jul 19 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dave Theese | last post by:
Hello all, The example below demonstrates proper conformance to the C++ standard. However, I'm having a hard time getting my brain around which language rules make this proper... The error...
3
by: seesaw | last post by:
Compared to "public", how does "private/protected" in inheritance change relationship between classes what is the purpose to define constructor as "private/protected"? is there any usage to...
10
by: Ioannis Vranos | last post by:
May someone explain why does this compile? class HiddenSealBaseClass { public: HiddenSealBaseClass() { } }; class Sealed: virtual HiddenSealBaseClass
2
by: MJ | last post by:
Hi I have a following sample code class base and class derived. I have inherited the base class as private and tried to compile the code its giving an error "conversion from 'class derived *' to...
1
by: Tony Johansson | last post by:
Hello! Private inheritance is sometimes called implementation inheritance. If you use this private inheritance how is with the usage of overriding then. Is overriding used less often when...
8
by: __PPS__ | last post by:
Hello everybody, today I had another quiz question "if class X is privately derived from base class Y what is the scope of the public, protected, private members of Y will be in class X" By...
6
by: karthikbalaguru | last post by:
Hi, Could someone here tell me some links/pdfs/tutorials to know about the difference between Private Inheritance and Public Inheritance ? I am unable to get info w.r.t it. Thx in advans,...
8
by: puzzlecracker | last post by:
The statement is taken from FAQ . What about non-virtual functions? Can they be overriden? I still don't see a good justification to prefer private inheritance over composition. In fact, I have...
13
by: PragueExpat | last post by:
I (think) that I've come up with a pattern that I haven't seen in any publications so far and I would like some feedback. Basically, I was looking for a way to inherit private functions and I came...
4
by: zhangyefei.yefei | last post by:
i read book <effective c++>,it tell me that public inheritance means is-a ,and private inheritance means is-implemented-in-terms-of. but today i am puzzled by some strange codes. the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.