473,789 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Small inheritance problem.

I have a situation witch is like this:

// A.h
class A
{
class AA
{
};
};

// B.h
class B
{
class BB : public A::AA
{
BB();
};
};

// B.cpp
B::BB::BB() : A::AA(args)
{
}

The compiler error is: multiple definition of BB()
when I try to implement the constructor.

Have a nice day,
Mihai.

Jul 23 '05 #1
5 1253
mihai wrote:
I have a situation witch is like this:

// A.h
class A
{
class AA
{
};
};

// B.h
class B
{
class BB : public A::AA
{
BB();
};
};

// B.cpp
B::BB::BB() : A::AA(args)
Add 'inline' before this function.
{
}

The compiler error is: multiple definition of BB()
when I try to implement the constructor.


When you define a function in the header and include that header
in more than one translation unit, you get multiple definitions.
Instead, you should define the function in only one translation
unit or declare it 'inline'.

V
Jul 23 '05 #2
Thank you for your answer.
I have fixed this up. But there is another problem on MVC 6.0 it seems
that the cod does not compile, and with gcc 3.4 it works. I don't see
how this can be. There are both standard compilers, no?

Jul 23 '05 #3
Hi,

Yes...MSVC 6.0 and gcc 3.4 are both standard compilers...how ever their
individual conformance to ISO C++ standards varies...MSVC 6.0 is 8
years old...so the compiler conformance to C++ standard dates back to
that time...maybe this particuar case was not included in affirmatives
part of standard so it gives compiler error...however gcc 3.4 follows
more latest c++ standrads and thus enables successfull compilation...

Just an issues of which standard is followed by compiler...thus use
latest compiler...GNU based gcc for *NIX and *NUX or cygwin mingw for
*dows is good...

Thanks
a.a.cpp

Jul 23 '05 #4
Isn't it class AA is private inner class of A and call to A::AA
should give compiler error ?

Thasks
Ganesh

Samee Zahur wrote:
Yes...MSVC 6.0 and gcc 3.4 are both standard compilers...how ever

their
individual conformance to ISO C++ standards varies...MSVC 6.0 is 8
years old...


Indeed, AFAIK the ISO C++ standard was published for the first at
around the same time, so it's rather a big(!) ask for MSVC 6.0 to
conform to it when even the later versions are not that good at it :(

Samee


Jul 23 '05 #5
Yes it is ... :)
But in my code it is not ...
This is why it compiles on gcc.

Mihai.

Jul 23 '05 #6

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

Similar topics

2
4382
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two files containing some templates: adjacency_list.hpp and mem_fn.hpp can not compile. Does anyone have any solutions?
7
1201
by: Richard Pope | last post by:
I have some existing code that I am trying to upgrade to c++. The data in question is two bytes, which are used to identify what information is requested from an industrial computer (a PLC). The first few bits represent the "category" of the data, and determine how the rest of the two bytes are interpreted. The existing code extracts various details from the data, but always uses a switch statement on the category. I could write a...
3
2473
by: Morten Aune Lyrstad | last post by:
Hi again! I'm having problems with inheritance. I have a base interface class called IObject. Next I have two other interfaces classes, IControl and ICommandMaster, which derives from IObject. My problem is that I have a /third/ class, CCommand, which derives from both IControl and ICommandmaster... The error message says (Weird.....)
22
23385
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete examples?
6
2102
by: VR | last post by:
Hi, I read about Master Pages in ASP.Net 2.0 and after implementing some WinForms Visual Inheritance I tryed it with WebForms (let's say .aspx pages, my MasterPage does not have a form tag itself so, cannot be called a WebForm itself, the child pages will implement forms). I created a Master.aspx page and removed all HTML from it, added some code to the .aspx.vb file to add controls to my page. Then I created a Child.aspx and changed the...
17
2540
by: Student | last post by:
Hi All, I have an assignment for my Programming language project to create a compiler that takes a C++ file as input and translate it into the C file. Here I have to take care of inheritance and operator overloading and virtual functions. I mean it should not hamper the C++ meaning. In frank and simple terms i need to implement a small C++ compiler in C++, and i want the intermediate representation to be C. Please help me in this....
5
2758
by: colint | last post by:
Hi I'm fairly new to c++ and I have a question regarding inheritance. I'm trying to create a class based on 2 inherited classes, e.g. class A { ... } class B: public A
169
9221
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide untaking to create a toolchain for it. Way back when, there used to be something called "Small C". I wonder if the creator(s) of that would want to embark on creating a nice little Small C++ compiler devoid of C++ language features that make...
5
3515
by: a | last post by:
Hi, I have an oop inheritance graph problem. What is the difference betweent the following 2 inheritance graph? How does the C++ solve the naming conflict problem for multiple inheritance problem? Thanks A / \
3
2904
by: Leo Seccia | last post by:
Hello everyone, I have a c# project with a sql server database. I have a number of lookup tables in my database which I successfully managed to import into my LINQ dataclasses. eg. Table: tlkpColor (PK) tlkpColorID
0
9666
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10200
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9020
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5418
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2909
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.