473,587 Members | 2,316 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::c out<<"FooToo ";};

};

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

};

main (){
FooTooBar x;
}

should x be instantiated o should it give compiler error?
Jul 19 '05 #1
14 5708
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::c out<<"FooToo ";};

};

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

};

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::c out<<"FooToo ";};

};

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

};

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

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

Similar topics

4
12808
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 below *should* happen, but my question to the community is *why* does it happen? Any answer will be appreciated, but a section and paragraph number...
3
2930
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 define destructor as "private/protected"? Thanks!
10
2479
by: Ioannis Vranos | last post by:
May someone explain why does this compile? class HiddenSealBaseClass { public: HiddenSealBaseClass() { } }; class Sealed: virtual HiddenSealBaseClass
2
2513
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 'class base *' exists, but is inaccessible" If I inherit using public it works well ... I am not very clear about the private inheritance
1
448
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 having private inheritance then when you have public inheritance. I just want to have you opinion about this matter.
8
7823
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 scope they meant public/protected/private access modifiers :) Obviously all members of the base privately inherited class will be private, and that was...
6
4402
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, Karthik Balaguru
8
2032
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 never seen it in a commercial code. If someone did, please share the use-case and decisions behind it. Thanks
13
1711
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 up with this: //base private object constructor function priv(){ this.a = 1; this.b = 2;
4
1809
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 following program can not pass compiling , bailing : g++ d.cpp -o d d.cpp: In function `int main()': d.cpp:27: error: `a' is an inaccessible base of...
0
7915
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8205
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6619
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.