This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: [C++] Derive a class from a tamplate
- From: corey taylor <corey dot taylor at gmail dot com>
- To: stefano luceri <stefano at communicationfactory dot it>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sun, 31 Jul 2005 13:23:31 -0500
- Subject: Re: [C++] Derive a class from a tamplate
- References: <42ED0F30.9050504@communicationfactory.it>
- Reply-to: corey taylor <corey dot taylor at gmail dot com>
stefano,
After taking a quick look at valarray, it seems that operator
overloads that declare operator+ for valarray are non-member
functions.
You will need to declarea set of operator+ overloads for mvector in
the same style as valarray overloads. I think this is the problem
you're seeing.
Is there a reason you're trying to force a copy with the code above?
corey
On 7/31/05, stefano luceri <stefano@communicationfactory.it> wrote:
> Hello to all .... excuse for my bad english
>
> I've the following problem writing a simple program. I would use the
> metods of std::valarray class adding some self writed method for elemnts
> of double type.
>
> I've thought something like this:
>
> /****************************/
> using namespace std;
>
> class mvector : public valarray<double>
> {
> mvector();
> mvector(int size);
> }
>
> mvector :: mvector() : valarray<double>() {}
> mvector :: mvector(int size) : valarray<double>(size) {}
>
> int main()
> {
> mvector v(3);
>
> v = (v+2.0);
> }
>
> /*****************************/
>
> Compiling this code I obtain the following error:
>
> geom.cpp: In function `int main()':
> geom.cpp:38: error: no match for 'operator=' in 'v = std::operator+(const
> std::valarray<_Tp>&, const _Tp&) [with _Tp = double]((&1.0e+0))'
> geom.cpp:22: error: candidates are: mvector& mvector::operator=(const
> mvector&)
> make: *** [geom.o] Error 1
>
> Why can't I use the operator = like I do with valarray?
>
>
>
>
>
>