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

namespace and inheritance issue

Hi all,
I don't know if this is just a "bug" in VisualStudio 6 or if I've
missed something...
If I do like this:

namespace NS
{

class CA
{
int A;
public:
virtual void Func() { A = 0; }
};

}

class CB : public NS::CA
{
int B;
public:
virtual void Func() { B = 0; NS::CA::Func(); }
};

the compiler gives 'illegal call of non-static member function'-error
message but if i add:
using namespace NS;
and removes NS:: it compiles fine.

Anyone knows?

Thanks in advance
/ Tomas
Jul 19 '05 #1
4 4344
> Hi all,
I don't know if this is just a "bug" in VisualStudio 6 or if I've
missed something...
If I do like this:

namespace NS
{

class CA
{
int A;
public:
virtual void Func() { A = 0; }
};

}

class CB : public NS::CA
{
int B;
public:
virtual void Func() { B = 0; NS::CA::Func(); }
};

the compiler gives 'illegal call of non-static member function'-error
message but if i add:
using namespace NS;
and removes NS:: it compiles fine.

Anyone knows?


Your code compiles fine with the Comeau compiler
(http://www.comeaucomputing.com/tryitout/). I suspect it is an issue
with the MSVC 6 compiler (no surprise). If you change B::Func() to { B =
0; CA::Func(); } it compiles on both.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl


Jul 19 '05 #2
On Wed, 08 Oct 2003 03:41:55 -0700, Tomas wrote:
the compiler gives 'illegal call of non-static member function'-error
message but if i add:
using namespace NS;
and removes NS:: it compiles fine.


g++ seems to think it's proper c++, no error, not even a warning (as does
my very quick visual examination) Time to check what language features
your copy of VC supports.

Output of my test:

$ cat test.cpp
namespace NS
{

class CA
{
int A;
public:
virtual void Func() { A = 0; }
};
}
class CB : public NS::CA
{
int B;
public:
virtual void Func() { B = 0; NS::CA::Func(); }
};
int main() {
return 0;
}
$ g++ -Wall -ansi -pedantic -pedantic-errors test.cpp
$ g++ --version
g++ (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
hth

--
NPV
"Linux is to Lego as Windows is to Fisher Price." - Doctor J Frink

Jul 19 '05 #3

"Nils Petter Vaskinn" <no@spam.for.me.invalid> wrote in message
news:pa****************************@spam.for.me.in valid...

g++ seems to think it's proper c++, no error, not even a warning (as does
my very quick visual examination) Time to check what language features
your copy of VC supports.


VC 6 is mostly conforming, with a few glitches.
Jul 19 '05 #4
WW
jeffc wrote:
"Nils Petter Vaskinn" <no@spam.for.me.invalid> wrote in message
news:pa****************************@spam.for.me.in valid...

g++ seems to think it's proper c++, no error, not even a warning (as
does my very quick visual examination) Time to check what language
features your copy of VC supports.


VC 6 is mostly conforming, with a few glitches.


Like barely implemented templates support, completely screwed up function
template support (uses overloading rules where it should not with wrong name
mangling), completely wrong for loop scoping and quite a few other serious
glitches, which makes it very much non-conforming in its default mode. In
its conforming mode it is impossible to use the standard library. It was
pretty good when it was released, but today it is not really good as a
standard C++ compiler.

--
WW aka Attila
Jul 19 '05 #5

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

Similar topics

88
by: Tim Tyler | last post by:
PHP puts most of its functions into a big flat global namespace. That leads to short function names - but creates a namespace minefield for programmers. Lots of the functions are legacies from...
11
by: Ricky Romaya | last post by:
Hi, Are there any ways to get multiple inheritace in PHP4? For example, I have 3 parent class, class A, B, and C. I want class X to inherit all those 3 classes. Consider merging those 3 classes...
4
by: JKop | last post by:
I'm starting to think that whenever you derive one class from another, that you should use virtual inheritance *all* the time, unless you have an explicit reason not to. I'm even thinking that...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
22
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...
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
6
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...
11
by: PAul Maskens | last post by:
The form designer adds unnecessary code to the section when using a subclassed control. I've reproduced this in VS.NET 2002 and VS.NET 2003 so it's pretty fundamental. Outline steps: Create a...
3
by: Al Grant | last post by:
Consider two translation units, (1): namespace { struct S { }; } struct D: S { virtual int f(void); }; and (2): #include <typeinfo> struct D; char const *f(D *p) { return...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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:
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.