#include<iostre am>
using namespace std;
class base
{
public:
void display()
{
}
};
class derived : public base
{
public:
void display(int i )
{
}
};
int main()
{
derived d;
d.display(1);
}
can anyone tell me that display funcion in derived class is a
overriding function or overloading function 8 3216
yashwant pinge wrote:
#include<iostre am>
using namespace std;
class base
{
public:
void display()
{
}
};
class derived : public base
{
public:
void display(int i )
{
}
};
int main()
{
derived d;
d.display(1);
}
can anyone tell me that display funcion in derived class is a
overriding function or overloading function
Neither.
Overloading concerns names in the same scope. Derived class'
scope is different than the base class' scope.
Overriding concerns virtual functions. There are no virtual
functions in your example.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
On Apr 16, 5:42 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
yashwant pinge wrote:
#include<iostre am>
using namespace std;
class base
{
public:
void display()
{
}
};
class derived : public base
{
public:
void display(int i )
{
}
};
int main()
{
derived d;
d.display(1);
}
can anyone tell me that display funcion in derived class is a
overriding function or overloading function
Neither.
Overloading concerns names in the same scope. Derived class'
scope is different than the base class' scope.
Overriding concerns virtual functions. There are no virtual
functions in your example.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
But the derived class is inherited from the base class .
As per the concepts of inheritance all the functions in base class is
inherited in the derived class so the derived class cotains the two
functions display with no parameters and with int parameter
so is it overloading functions in derived class...?
yashwant pinge wrote:
On Apr 16, 5:42 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
>yashwant pinge wrote:
>>#include<iost ream> using namespace std;
>>class base { public: void display() { } };
>>class derived : public base { public: void display(int i ) { } };
>>int main() { derived d; d.display(1); }
>>can anyone tell me that display funcion in derived class is a overriding function or overloading function
Neither.
Overloading concerns names in the same scope. Derived class' scope is different than the base class' scope.
Overriding concerns virtual functions. There are no virtual functions in your example.
V -- Please remove capital 'A's when replying by e-mail I do not respond to top-posted replies, please don't ask
But the derived class is inherited from the base class .
The proper term is either "is derived from" or "inherits from" or
"derives from".
As per the concepts of inheritance all the functions in base class is
inherited in the derived class so the derived class cotains the two
functions display with no parameters and with int parameter
I am not sure what you mean by "contains".
so is it overloading functions in derived class...?
No, it is not (see my explanantion above). The 'base::display' member
is _hidden_ in 'derived'. Without special actions, the 'display' with
no arguments is not callable with/from 'derived'.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
As I understand it, class derived has two functions "display" because
they have a diffent signature. Overriding a function implies that the
method has the same signature but different implementation.
Gaijinco wrote:
As I understand it, class derived has two functions "display" because
they have a diffent signature. Overriding a function implies that the
method has the same signature but different implementation.
Understand what?
--
Ian Collins.
Oh yeah I was very wrong, I tried to code some examples and the
compiler always said that display() from "base" is not accessible from
"derived" but I don't understand something: Can I overload a method
that was inherited?
On Apr 17, 6:37 am, Gaijinco <gaiji...@gmail .comwrote:
Oh yeah I was very wrong, I tried to code some examples and the
compiler always said that display() from "base" is not accessible from
"derived" but I don't understand something: Can I overload a method
that was inherited?
test.cpp: In function `int main()':
test.cpp:27: no matching function for call to `derived::displ ay()'
test.cpp:18: candidates are: void derived::displa y(int)
Why it should be?
On Apr 17, 7:48 am, yashwant pinge
<yashwantpi...@ gmail.comwrote:
On Apr 17, 6:37 am, Gaijinco <gaiji...@gmail .comwrote:
Oh yeah I was very wrong, I tried to code some examples
and the compiler always said that display() from "base"
is not accessible from "derived" but I don't understand
something: Can I overload a method that was inherited?
test.cpp: In function `int main()':
test.cpp:27: no matching function for call to
`derived::displ ay()'
test.cpp:18: candidates are: void derived::displa y(int)
Why it should be?
I believe that's what FAQ 23.9 is all about. http://www.parashift.com/c++-faq-lit....html#faq-23.9
--
Pavel Lepin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: BDob |
last post by:
Standard documents "Access control is not considered in determining
overriding."
To further explain what's puzzling me, I put up an example below:
class Base
{
public:
virtual void Method1(int a);
void Method2(int b);
|
by: Xiangliang Meng |
last post by:
Hi, all.
When reading C++ books, I'm alway confused by those terms "redefining
functions", "overloading functions" and "overriding functions".
Please give me some comments on those terms. Thanks.
If giving more strategy hehind them, more helpful.
Best Regards,
|
by: iceColdFire |
last post by:
Hi,
What is the Diff btwn Function overloading and overriding
thanks,
a.a.cpp
|
by: Iyer, Prasad C |
last post by:
I am new to python.
I have few questions
a. Is there something like function overloading in python?
b. Can I overload __init__ method
Thanks in advance
regards
|
by: JaSeong Ju |
last post by:
I would like to overload a C function. Is there any easy way to do this?
| |
by: Ratnakar .N |
last post by:
HELLO,
Please tell me the main difference between method overriding and method overloading
Thank you
|
by: Achim Domma |
last post by:
Hi,
I want to use Python to script some formulas in my application. The user
should be able to write something like
A = B * C
where A,B,C are instances of some wrapper classes. Overloading * is no
problem but I cannot overload the assignment of A. I understand that
this is due to the nature of Python, but is there a trick to work around
|
by: Zach |
last post by:
Consider the following code:
void Test(int i)
{
System.Console.WriteLine("int function");
}
void Test(object o)
{
System.Console.WriteLine("object function");
|
by: ramadeviirrigireddy |
last post by:
Can anyone tell me whether the return type of the method will also be considered when you are overriding a method? what i mean exactly is whether the return type can be different when you are overriding a method.and somewhere i read like overloading will not come under polymorphism. is this true?
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |