C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 08-06-2002, 06:05 AM   #1
Registered User
 
Join Date: Jul 2002
Posts: 29
thisfunction = thatfunction (?)

I have this problem:

I have a class (let us call it A). A contains a function called doit(). Every time I need to make doit() different, I have to make a subclass, and change it virtually. Is there a smarter way around this?
__________________
I like traffic lights. I like traffic lights. I like traffic lights, but only when they're green.
Skarr is offline   Reply With Quote
Old 08-06-2002, 06:35 PM   #2
geek
 
SilentStrike's Avatar
 
Join Date: Aug 2001
Location: NJ
Posts: 1,141
That is certainly one way of doing it. If you don't care to be able to use functions that "doit", the subclassing solution is ok. If you want to be able to use functions as well as classes, you might want to check this thread, about functors.

http://www.cprogramming.com/cboard/s...light=template

Replace the check member function with doit, and I think you have the same problem as the person from that post.
__________________
Prove you can code in C++ or C# at TopCoder, referrer rrenaud
Read my livejournal
SilentStrike is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump


All times are GMT -6. The time now is 03:59 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22