473,412 Members | 2,096 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,412 software developers and data experts.

operator which cant be inherited??

hello,

can anyone tell me which is the operator in c++ which can be overloaded but cannot be inherited??
Jul 4 '07 #1
3 1331
weaknessforcats
9,208 Expert Mod 8TB
Operators are not inherited.
Jul 5 '07 #2
Operators are not inherited.
OPERATORS can and are Inherited.. except for "=" operator in c++
It must be redefined in the derived class.
Jul 22 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
Operators are not inherited.

A Base::operator+() has no idea how to add two derived objects since the derived objects have members not in the base class.

In fact, when you code the Derived::operator+(), you have call
Base::operator+():
Expand|Select|Wrap|Line Numbers
  1. Derived Derived::operator+(const Derived& rhs) const
  2. {
  3.      Base::operator+(*this);
  4.      //then do the derived members.
  5. }
  6.  
Jul 24 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Juha Tenhosaari | last post by:
Hello, I wonder if anyone could tell me why the operator= is not inherited into the derived class in the following code: class A { public: void operator=(int i){a=i;} int a;
1
by: Russ Ford | last post by:
Hi all, I'm trying to get inheritance and constructors clear in my head (and in my code). I have the following inheritance situation (all derivations public): A is the base class B is...
8
by: trying_to_learn | last post by:
Why do we need to explicitly call the copy constructor and the operator = , for base class and member objects in composition? ....book says "You must explicitly call the GameBoard copy-constructor...
3
by: Alicia | last post by:
Hello, I am trying to figure out how to call an overloaded operator<< inherited from a base class. #ifndef PHONECALL #define PHONECALL #include "time.h" #include "interval.h"
2
by: frantz | last post by:
Maybe a stupid question: ------------------------ Is there ihneritance for conversion operator? If yes or no, what is the reason(s)... Thanks for your help. Example: -------- class A {
7
by: vj | last post by:
Hi Friends, I was going through a C++ reference book when this rule caught my eye: -->Assignment operator '=' is not inherited by the sub class. I cannot figure out why this rule has being...
5
by: tom | last post by:
Hi, I'm overriding my operator new and operator delete for two classes, one inherited from the other, so I can use my own memory pool. A simplified version of what I have is below: class...
11
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...
7
by: Daniel Kraft | last post by:
Hi all! I'm getting some for me "unexpected behaviour" from g++ 4.1.2 when compiling this simple test program: #include <cstdlib> #include <cstdio> using namespace std; template<typename...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
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,...
0
isladogs
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...
0
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...

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.