473,394 Members | 1,699 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,394 software developers and data experts.

question about multi base classes

Hi,

A piece of description about multi inheritance in ISO/ANSI C++ standard is
as following:

A class shall not be specified as a direct base class of a derived class
more than once.
[Note: a class can be an indirect base class more than once and can be a
direct and an indirect base class. ]
Example:

class X { /* ... */ };
class Y : public X, public X { /* ... */ }; // illformed
class L { public: int next; /* ... */ };
class A : public L { /* ... */ };
class B : public L { /* ... */ };
class C : public A, public B { void f(); /* ... */ }; // wellformed
class D : public A, public L { void f(); /* ... */ }; // wellformed

if above class D is OK. why can't the following code be compiled with Visual
C++

#include "stdafx.h"
#include<iostream>
class v
{};
class b:public v
{};
class e:public v
{};
class d:public b,public v
{};
int main()
{ return 0;}

But the following code work well.

#include "stdafx.h"
#include<iostream>
class v
{};
class b:public v
{};
class e:public v
{};
class d:public b,public e
{};
int main()
{ return 0;}
thanks in advance
Michael
Jul 19 '05 #1
1 1342

"Michael" <mi**********@sympatico.ca> wrote in message
news:AF********************@news20.bellglobal.com. ..
Hi,

A piece of description about multi inheritance in ISO/ANSI C++ standard is
as following:

A class shall not be specified as a direct base class of a derived class
more than once.
[Note: a class can be an indirect base class more than once and can be a
direct and an indirect base class. ]
Example:

class X { /* ... */ };
class Y : public X, public X { /* ... */ }; // illformed
class L { public: int next; /* ... */ };
class A : public L { /* ... */ };
class B : public L { /* ... */ };
class C : public A, public B { void f(); /* ... */ }; // wellformed
class D : public A, public L { void f(); /* ... */ }; // wellformed

if above class D is OK. why can't the following code be compiled with Visual C++

#include "stdafx.h"
#include<iostream>
class v
{};
class b:public v
{};
class e:public v
{};
class d:public b,public v
{};
int main()
{ return 0;}

But the following code work well.

#include "stdafx.h"
#include<iostream>
class v
{};
class b:public v
{};
class e:public v
{};
class d:public b,public e
{};
int main()
{ return 0;}
thanks in advance
Michael


Once I'd removed #include "stdafx.h" both your examples compiled with my
copy of VC++ 7.1. The first one produced a warning but that is all.

If you think you've found a compiler bug you should take it up in a VC++
newsgroup (e.g. news:microsoft.public.vc.language) and state which version
you are using. Nothing wrong with either code sample that I can see.

john
Jul 19 '05 #2

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

Similar topics

77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
21
by: Jon Slaughter | last post by:
I have a class that is basicaly duplicated throughout several files with only members names changing according to the class name yet with virtually the exact same coding going on. e.g. class...
8
by: Shaun C Farrugia | last post by:
I have a multi team solution being built where teams are segmented off into seperate projects. One project is an over all framework containing a Broker class responsible for instantiating...
3
by: Kurt | last post by:
i just can't figure out why something im doing is not working correctly.... public interface IInterface { int someProperty { get; set; }
13
by: John Salerno | last post by:
Hi all. I have a question about interfaces now. According to the book I'm reading, when you implement an interface, the class or structure has to declare all the methods that the interface...
6
by: Peter Oliphant | last post by:
I just discovered that the ImageList class can't be inherited. Why? What could go wrong? I can invision a case where someone would like to add, say, an ID field to an ImageList, possible so that...
6
by: tshad | last post by:
I am playing with Inheritance and want to make sure I understand it. I have the following Classes: ******************************************* Public Class AuthHeader:Inherits SoapHeader Public...
1
by: Will | last post by:
Our shop has 6 .Net developers, most of our work to date has been one developer on a project at a time, occasionally 2 for brief periods of time. We have souce control (SourceGear) and love what...
9
by: Mike Hofer | last post by:
In a large application I'm working on (ASP.NET 1.1, VS2003), we have a base class that wraps stored procedures. Essentially, this base class (StoredProcedureBase) encapsulates the code to set up...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.