473,396 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,396 software developers and data experts.

Overloading in subclass

Let's say I have the following:

class Foo {
public:
void func();
};

class Bar : public Foo {
public:
void func() {
// do some work...

this->Foo::func();
}
}

Now, if I have an object b of type Bar, and I call b.func(), it will
call b.Bar::func(), which in turn will call b.Foo::func(), correct?
Joseph

Jul 23 '05 #1
3 1261
Joseph Turian wrote in news:1118876638.997229.221340
@z14g2000cwz.googlegroups.com in comp.lang.c++:
Let's say I have the following:

class Foo {
public:
void func();
};

class Bar : public Foo {
public:
void func() {
// do some work...

this->Foo::func();
}
}

Now, if I have an object b of type Bar, and I call b.func(), it will
call b.Bar::func(), which in turn will call b.Foo::func(), correct?


Correct.
Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 23 '05 #2
Joseph Turian wrote:
Let's say I have the following:

class Foo {
public:
void func();
};

class Bar : public Foo {
public:
void func() {
// do some work...

this->Foo::func();
}
}

Now, if I have an object b of type Bar, and I call b.func(), it will
call b.Bar::func(), which in turn will call b.Foo::func(), correct?


Right.
Jul 23 '05 #3
"Joseph Turian" <tu****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Let's say I have the following:

class Foo {
public:
void func();
};

class Bar : public Foo {
public:
void func() {
// do some work...

this->Foo::func();
You can just write Foo::func(); here.
}
}

Now, if I have an object b of type Bar, and I call b.func(), it will
call b.Bar::func(), which in turn will call b.Foo::func(), correct?


Yes. You aren't really "overloading" here, since the compiler is not
choosing which of several functions to call based on their argument lists.

DW
Jul 23 '05 #4

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

Similar topics

2
by: cppsks | last post by:
Here is the code that I am working with: #include <new> #include <iostream> #include "stdlib.h" class Base1 { public: Base1() { cout << "Base1:" << this << endl; }
0
by: cppsks | last post by:
Hello. I posted a question regarding this yesterday. I came up with the following solution but I am a little hesistant as to this solution having any side-effects that I am not aware of. The...
15
by: Susan Baker | last post by:
Hello everybody, I'm new to C++ (I have some C background). I've read up on this topic a few times but it just dosen't seem to be sinking in. 1. Whats the difference between overloading and...
3
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
11
by: James Stroud | last post by:
Hello All, How does one make an arbitrary class (e.g. class myclass(object)) behave like a list in method calls with the "*something" operator? What I mean is: myobj = myclass() ...
15
by: Brian Haynes | last post by:
I am having a problem with overloading. An example: Public Class Base ... End Class Public Class Derived Inherits Base ... End Class
6
by: Massimo Soricetti | last post by:
Hello, recently I wrote a little class which has to wrap two different type of data, showing the same external interface. I used operator overloading, but the same result I could eventually...
4
by: saadsj | last post by:
Hello, I'm in a situation where I'm using a library object that happens to have a bug in one of its operators. This bug was recently introduced into a new release of their library....
11
by: placid | last post by:
Hi all, Is it possible to be able to do the following in Python? class Test: def __init__(self): pass def puts(self, str): print str
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:
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
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...
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,...

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.