Mail Archives: djgpp/2000/07/11/11:30:20
From: | paul DOT bibbings AT tesco DOT net (Paul Bibbings)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | DJGPP - failure to implement namespaces properly
|
Date: | Tue, 11 Jul 2000 14:52:25 GMT
|
Organization: | Customer of Planet Online
|
Lines: | 81
|
Message-ID: | <396b310a.33541001@news.freeserve.net>
|
NNTP-Posting-Host: | modem-220.tellurium.dialup.pol.co.uk
|
X-Trace: | newsg4.svr.pol.co.uk 963327153 9024 62.136.43.220 (11 Jul 2000 14:52:33 GMT)
|
NNTP-Posting-Date: | 11 Jul 2000 14:52:33 GMT
|
X-Complaints-To: | abuse AT theplanet DOT net
|
X-Newsreader: | Forte Free Agent 1.21/32.243
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Don't get me wrong, as a novice C++ programmer I have no doubt that
DJGPP/Rhide is my favourite compiler/IDE combination, and that is why
I am all the more frustrated when it seems it doesn't implement the
language in ways the textbooks would expect it to. Maybe I'm missing
something (and I apologise if that's the case) but it seems to me
DJGPP can get all at sea with namespaces, and in particular with the
use of using declarations. I have come across many instances of this,
and currently I have been stumped by the fact that it will not allow
me to using using declarations to implement overloaded functions
across base/derived class boundaries.
The following snippet, adapted from Stroustrup (3rd ed) 15.2.2
simply won't compile.
#define nonstandard
#include <iostream>
#include <cstdlib>
#ifdef nonstandard
#include <conio.h>
#endif
using std::cout;
using std::endl;
class A{
int i;
char c;
public:
A(): i(0), c(0) {}
A(int ii): i(ii), c(0) {}
A(char cc): i(0), c(cc) {}
A(int ii, char cc): i(ii), c(cc) {}
int get_int() const {return i;}
char get_char() const {return c;}
int f(int ii) {cout << "In A::f(int)..." << endl; return 2 * i;}
char f(char c) {return i;} // implicit cast int to char
};
class B{
double d;
public:
B(double dd = 0): d(dd) {}
double get_double() const {return d;}
double f(double dd) {return d/2;}
};
class AB: public A, public B{
public:
AB(int ii = 0, char cc = 0, double dd = 0): A(ii, cc), B(dd) {}
using A::f; //******************************* problem
using B::f; //******************************* lines
char f(char c) {return c;} // hides a::f(char)
AB f(AB); // line 52
};
int main()
{
cout << "Token main()..." << endl;
return EXIT_SUCCESS;
}
failing with the error messages
C:\c++projs\inherit_using.cpp:53: cannot adjust access to `char
A::f(char)' in `class AB'
C:\c++projs\inherit_using.cpp:52: because of local method `class AB
AB::f(AB)' with same name
C:\c++projs\inherit_using.cpp:53: cannot adjust access to `double
B::f(double)' in `class AB'
C:\c++projs\inherit_using.cpp:52: because of local method `class AB
AB::f(AB)' with same name
Process completed with exit code 1
This seems like a significant failing on the compiler's part, since
the technique of overloading across inheritance boundaries is
something I, at least, can imagine using often.
- Raw text -