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

Problem with overriding Functions (oop)

Hi,

i'va got a class 'Page'. One of it members is an instance of a template engine.
The Page-class has a method render() which calls the functions read(),
transform(), transport() and starts the template engine.

Now I want to reuse the Page class for a more specialized page 'ImagePage'. So:
ImagePage extends Page. This Page contains an extra picture and therefore needs
to call image() before starting the template engine. How do i smartly integrate
that call into the Page::render() function.

I could override the whole funtion, but then i'd have to copy and paste the
whole code for the calls of read(), transform(), transport()?
What's the professional way here?

Johannes
Jan 19 '08 #1
1 1298
On Sun, 20 Jan 2008 00:32:16 +0100, Johannes Permoser <ee***@yahoo.de>
wrote:
Hi,

i'va got a class 'Page'. One of it members is an instance of a template
engine. The Page-class has a method render() which calls the functions
read(), transform(), transport() and starts the template engine.

Now I want to reuse the Page class for a more specialized page
'ImagePage'. So: ImagePage extends Page. This Page contains an extra
picture and therefore needs to call image() before starting the template
engine. How do i smartly integrate that call into the Page::render()
function.

I could override the whole funtion, but then i'd have to copy and paste
the whole code for the calls of read(), transform(), transport()?
What's the professional way here?

class ImagePage extends Page{
function render($arg){
$this->image();
parent::render($arg);
}
}

--
Rik Wasmus
Jan 19 '08 #2

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

Similar topics

99
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less...
8
by: Edward Diener | last post by:
Is it possible for a derived class to override a property and/or event of its base class ?
1
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....
2
by: Julian | last post by:
I would like to have output from my program to be written to cout as well as a file. (actually, i want several other output options but this should explain my problem in the simplest way). I have...
2
by: franklini | last post by:
hello people i. can anybody help me, i dont know what is wrong with this class. it has something to do with the me trying to override the input output stream. if i dont override it, it works fine....
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...
59
by: Mr. x | last post by:
Hello, I need a good help/tutorial for VB, please (I preffer *.chm help file). Also : for the function : now() in VBScript for getting the current time, what is the counterpart function of VB ?...
5
by: Leslaw Bieniasz | last post by:
Hello, I have the following OOP design problem. I have a base class designed as an element of a list, let's say: class A { public: // some stuff
4
by: srinivasarao_moturu | last post by:
class ABC { public : virtual void operation1(); virtual void operation2(); virtual int GetValue(); virtual char GetValue(); virtual void SetValue(int); virtual void SetValue(char); }
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
tracyyun
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...

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.