Hi all,
For some reason, my derived class does not inherit the operator '=' of my base class, which is a class template, when I compile with g++
//=========== base class
template<class T>
class vec{
public:
vec &operator=( vec ) ;
};
//=========== derived class
class vec_d : vec<double> {
};
//===========
When I compile, I have the following error:
no match for `vec_d& = vec<double>' operator
candidates are: vec_d& vec_d::operator =(const vec_d&)
Any ideas, please???
jose, 2 1293
jmborr wrote: Hi all, For some reason, my derived class does not inherit the operator '=' of my base class, which is a class template, when I compile with g++ //=========== base class template<class T> class vec{ public: vec &operator=( vec ) ; }; //=========== derived class class vec_d : vec<double> { }; //===========
When I compile, I have the following error: no match for `vec_d& = vec<double>' operator candidates are: vec_d& vec_d::operator =(const vec_d&)
When in doubt, simplify. The problem has nothing to do with templates.
Read about assignment operators and inheritance.
--
Pete Becker
Dinkumware, Ltd. ( http://www.dinkumware.com)
jmborr wrote: Hi all, For some reason, my derived class does not inherit the operator '=' of my base class,
The reason is that operator= is never inherited.
which is a class template, when I compile with g++ //=========== base class template<class T> class vec{ public: vec &operator=( vec ) ;
With the above signature, the right hand vec will be copied into the
parameter before it then is copied into the this object. So you shuold
probably use a (const) reference:
vec& operator=(const vec&);
}; //=========== derived class class vec_d : vec<double> { }; //===========
Why don't you just typedef it?
typedef vec<double> vec_d;
When I compile, I have the following error: no match for `vec_d& = vec<double>' operator candidates are: vec_d& vec_d::operator =(const vec_d&)
Any ideas, please??? jose,
--
First they ignore you. Then they laugh about you.
Then they fight you. And then you win.
(Mahatma Gandhi) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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?
|
by: W. Cerven |
last post by:
I am using the C++ STL container "list" to create a template nested
list. Attached are my basic code and compiler errors. Oddly enough,
I when I create a non-template version of this nested list, I do not
get this problem. Any help someone could provide would be great.
Thanks.
nestedlisttemplate.h:
----------------------------
using...
|
by: Mikhail N. Kupchik |
last post by:
Hi All.
I have a question regarding Herb Sutter's idiom of implementation of
operator= via nonthrowing swap() member function, to guarantee strict
exception safety.
The idea of the idiom is shown by the example:
-- code fragment 1 ----------------------------------------------------
class MyClass
|
by: danilo.horta |
last post by:
Hi folks
I'm having a scope resolution issue. The gnu compiler is trying to
use the "operator function" from derived class rather than from correct
one, the base class.
// VecBasis.h file
template<class T, size_t numDim> class VecBasis {
protected:
|
by: Chris |
last post by:
Is there ever a reason to declare this as
if(*this == rhs)
as opposed to what I normally see
if(this == &rhs)
?
| |
by: Zilla |
last post by:
I have the following simple program. I just want to be able to do math
operations (+, -, =)on Timer sublcasses, but want to handle cases
where either rhs or lhs is an intrinsic value, However, the compile
fails in my g++ 2.95 compiler during the 2nd to last line of the
main() with
template.cpp: In function `int main()':
template.cpp:24:...
|
by: Joachim |
last post by:
Hello,
I have been trying to get the following code to work, but unfortunately
without any succes so far. I have searched in newsgroups and google but
found nothing there that could solve my problem.
Given the following classes :
template <class T>
class AAA{
int tabel;
public:
|
by: wo3kie |
last post by:
#include <iostream>
#include <map>
#include <utility>
//
// Base
// / | \
// Derived1 Derived2 \
// \ | /
// Derived3
|
by: Peng Yu |
last post by:
Hi,
In the following code, the 'copy' member function works. But the '='
operator does not work. Can somebody let me know why a member function
is different from an operator.
Thanks,
Peng
#include <iostream>
|
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...
|
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...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |