473,394 Members | 1,748 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,394 software developers and data experts.

Inheritance of overloaded functions

Hello,

To ease my frustration, could some give me an example that justifies why
They choose to invalidate the following piece of code:
class filter
{
public:
virtual void Put (const float Sample) = 0;
virtual float Get() const = 0;
virtual float Get (const float Sample)
{ Put (Sample); return (Get()); }
};

class filterDSP : public filter
{
public:
void Put (const float Sample);
float Get() const;
};

filerDSP dsp;

voif (float f)
{
return (dsp.Get (f)); // ERROR!!! WRONG
NUMBER OF ARGUMENTS
}
One could argue that this is due to r.13.1 But I need more ;-)

Thank you.

Jul 23 '05 #1
3 1186
Jean-Christophe MATHAE wrote:
To ease my frustration, could some give me an example that justifies why
They choose to invalidate the following piece of code:
class filter
{
public:
virtual void Put (const float Sample) = 0;
virtual float Get() const = 0;
virtual float Get (const float Sample)
{ Put (Sample); return (Get()); }
};

class filterDSP : public filter
{
public:
void Put (const float Sample);
float Get() const;
};

filerDSP dsp;

voif (float f) ^^^^^^^^^^^^^^
There is a syntax error somewhere in this line...
{
return (dsp.Get (f)); // ERROR!!! WRONG
NUMBER OF ARGUMENTS
The 'filterDSP::Get()' _hides_ the 'filter::Get(float)' function.
}
One could argue that this is due to r.13.1 But I need more ;-)


I guess that one could, but I wouldn't argue that. You have a very
simple case of *name hiding*.

V
Jul 23 '05 #2
On Mon, 20 Jun 2005 13:08:51 -0400, Victor Bazarov wrote:
The 'filterDSP::Get()' _hides_ the 'filter::Get(float)' function.

}

One could argue that this is due to r.13.1 But I need more ;-)


I guess that one could, but I wouldn't argue that. You have a very simple
case of *name hiding*.


Where does this name hiding feature arise and why? Other languages don't
seem to need it.
Jul 23 '05 #3
Joe P wrote:

Where does this name hiding feature arise and why? Other languages don't
seem to need it.


struct Base
{
};

struct Derived : Base
{
void f(double);
};

void test()
{
Derived d;
d.f(3);
}

So far, so good. Now imagine Base is defined in some third party
library, and in a maintenance release they change it:

stuct Base
{
void f(int);
};

If Base::f is considered in the possible matches for the call d.f(3) it
wins, and you've got a change in behavior.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Mike Frayn | last post by:
Hi there. I'm wondering how to achieve a particular functionality using virtual functions and class inheritance... I don't know if its possible, but I figured that I would give it a shot. What...
5
by: IvDČ | last post by:
During a project I ran into trouble when using multiple inheritance. I was able to resolve the problem, but was unable to really understand the reasons for the error. Here is a short example of...
7
by: lovecreatesbeauty | last post by:
The following shortened table comes from a big company's C++ technical document accompanied with its C++ compiler. This company's C++ compiler was/is very popular in Windows platform programming....
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
44
by: bahadir.balban | last post by:
Hi, What's the best way to implement an overloaded function in C? For instance if you want to have generic print function for various structures, my implementation would be with a case...
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
5
by: Noah Roberts | last post by:
Is there anything that says that if you virtually inherit from one class you have to virtually inherit from anything you inherit from?
3
by: Gary Wessle | last post by:
Hi this code of mine, is my first attempt at inheritance. it is buggy and I am sure there are few errors, it did not compile and I could not find out why, please help. thank you #include...
8
by: puzzlecracker | last post by:
The statement is taken from FAQ . What about non-virtual functions? Can they be overriden? I still don't see a good justification to prefer private inheritance over composition. In fact, I have...
7
by: =?Utf-8?B?QWxleCBDb2hu?= | last post by:
In C++, there is an easy technique to provide an overloaded Equals() method. A straightforward translation to C# causes a stack overflow. Why does b.Equals(ba) in the snippet below not understand...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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,...

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.