* Re: Problem with Compilerupdate 3.3.5 -> 4.0.2
@ 2006-02-01 17:21 Oliver Kullmann
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Kullmann @ 2006-02-01 17:21 UTC (permalink / raw)
To: Christian Weckmueller, gcc-help
On Wed, Feb 01, 2006 at 06:08:23PM +0100, Christian Weckmueller wrote:
> Hello dear gcc-helper,
>
> I have a program without problems compiling with 3.3.5 but don't work with
> 4.0.2. So here is the question: are there big differences in templates
> combined with inheritance between these versions?
>
> I give you a part of the code:
>
> template<typename T> class Vector{
>
> protected:
> T *vectorPtr;
> size_type dim; <<<<<
> unsigned short coutwidth;
> ...
> };
>
> template<typename T> class NumericVector : public Vector<T>{
>
> public:
> NumericVector() : Vector<T>(){}
> NumericVector(size_type dim) : Vector<T>(dim){}
> NumericVector(size_type dim, T initVal) : Vector<T>(dim,
initVal){}
> NumericVector( const Vector<T> &src );
>
> void makeHilb();
> };
>
> template<typename T> NumericVector<T>::NumericVector( const Vector<T> &src )
{
>
> dim = src.length();
<<<<<<<
> vectorPtr = NULL;
> unsigned short counter = 3;
> ...
> }
>
> in the program i use NumericVector. the compiler 4.0.2 says he don't know
> dim
> in the convertconstructor of NumericVector
>
> the older one is fine with this program.
>
> Can anybody explain why there is a problem?
>
> Thanks, cris
Hi,
g++ 4.0.2 is right, your code is incorrect:
since class template NumericVector uses a *dependant* base class Vector<T>,
members of this base class must be qualified. So to get access to dim
in that constructor, you need to call it
Vector<T>::dim
or
this -> dim.
(A using declaration
using Vector<T>::dim;
also does the job.)
Oliver
P.S. Search for "dependant names" in the index of
@Book{JV2002,
author = {David Vandevoorde and Nicolai M. Josuttis},
title = {C++ Templates: The Complete Guide},
publisher = {Addison-Wesley},
year = 2002,
address = {Boston},
month = {November},
note = {ISBN 0-201-73484-2; QA76.73.C153 V37 2003},
annote = {Vorhanden.}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Problem with Compilerupdate 3.3.5 -> 4.0.2
@ 2006-02-01 17:08 Christian Weckmueller
0 siblings, 0 replies; 2+ messages in thread
From: Christian Weckmueller @ 2006-02-01 17:08 UTC (permalink / raw)
To: gcc-help
Hello dear gcc-helper,
I have a program without problems compiling with 3.3.5 but don't work with
4.0.2. So here is the question: are there big differences in templates
combined with inheritance between these versions?
I give you a part of the code:
template<typename T> class Vector{
protected:
T *vectorPtr;
size_type dim; <<<<<
unsigned short coutwidth;
...
};
template<typename T> class NumericVector : public Vector<T>{
public:
NumericVector() : Vector<T>(){}
NumericVector(size_type dim) : Vector<T>(dim){}
NumericVector(size_type dim, T initVal) : Vector<T>(dim, initVal){}
NumericVector( const Vector<T> &src );
void makeHilb();
};
template<typename T> NumericVector<T>::NumericVector( const Vector<T> &src ){
dim = src.length(); <<<<<<<
vectorPtr = NULL;
unsigned short counter = 3;
...
}
in the program i use NumericVector. the compiler 4.0.2 says he don't know
dim
in the convertconstructor of NumericVector
the older one is fine with this program.
Can anybody explain why there is a problem?
Thanks, cris
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-01 17:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-01 17:21 Problem with Compilerupdate 3.3.5 -> 4.0.2 Oliver Kullmann
-- strict thread matches above, loose matches on Subject: below --
2006-02-01 17:08 Christian Weckmueller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).