Chat on IRC |
Static Polymorphism??
Posted by manoj [send private reply] at August 24, 2002, 01:55:22 PM
Is there something like static polymorphism? I've never heard of anything like that but someone asked me about it so I want to make sure. Also how do u make an abstract class in c++? I think the only way is to make a func pure virtual [void f() = 0;], is there any other way too?
Posted by unknown_lamer [send private reply] at August 24, 2002, 03:24:27 PM
Static polymorphism? Wtf? How does that make any sense at all? Polymorphism is supposed to be dynamic, static is the opposite of dynamic...as for abstract classes in C++, no; you can only create one by making one of the methods pure virtual. The constructor works well for this.
Posted by manoj [send private reply] at August 24, 2002, 04:07:39 PM
got it. thanx lamer
Posted by Psion [send private reply] at August 24, 2002, 05:26:54 PM
"Polymorphism is supposed to be dynamic" doesn't make much sense to me, but perhaps the issue is already closed.
Posted by balpeck [send private reply] at August 25, 2002, 12:00:30 PM
static polymorphism is nothing but function/operator overloading!
the function to called is determined at compile time ....hence its called static polymorphism!
Posted by taubz [send private reply] at August 25, 2002, 01:57:47 PM
Where'd that definition come from?
Posted by Psion [send private reply] at August 25, 2002, 01:59:53 PM
I think I'll add that ML/Haskell have much sexier polymorphism that has nothing to do with overloading. Check it out for yourself if you care!
Posted by unknown_lamer [send private reply] at August 25, 2002, 02:28:35 PM
Overloading is for LOSERS. Well, not always. But it is used far too much in "OO" programming. Just makes things more confusing. Yeah, having + work for number types and strings makes sense, but why do you need a + operator to add hamsters together?
C++ is a lame excuse for an Object Oriented Programming Language. Objective-C does this better, and CLOS seems to be one of the better Object Oriented langauge/packages. Then again, I seem to suck at OO programming, and so do most people (because OO isn't the be-all-end-all solution those OO-rocks people make it out to be).
Posted by CViper [send private reply] at August 25, 2002, 02:38:29 PM
Yeah. OO is waaay overrated...
Posted by RedX [send private reply] at August 25, 2002, 03:05:03 PM
"Objective-C does this better" You know object-C is M$ crapware so per definition it can't be better since that would violate several computer science laws. Just putting M$ on the box would already introduces several new bugs.
OOP has better PR than other methodes. Everybody has at least heard of it. But how many have heard of aspect oriented programming or extreme programming?
Posted by Psion [send private reply] at August 25, 2002, 04:15:45 PM
I wasn't aware that Microsoft even made any Objective C compilers.
Posted by gian [send private reply] at August 25, 2002, 06:33:51 PM
RedX: You aren't confusing Objective C with C#, are you?
Posted by RedX [send private reply] at August 25, 2002, 07:11:14 PM
Guess so. I think this proves win'98 is bad for the brain. Luckely I installed linux (Red Hat) last week and I've almost explored all the games and even got internet connection working too.
Posted by manoj [send private reply] at August 26, 2002, 05:43:31 AM
balpeck : If the func is to be determined at run time souldn't it be called dynamic? Its confusing. Also if that's static then what is dynamic? Plz explain.
I've somewhere read that the meaning of polymorphism is "many forms" (latin), now this is pretty clear for func/operators but u guys seem to be talking about something very different is there any other polymorphism I should know about (for C++)?
Posted by Psion [send private reply] at August 26, 2002, 08:09:56 AM
manoj, that was a very confusing message you posted. Maybe you should read balpeck's reply again and see if you misunderstood it?
Posted by taubz [send private reply] at August 26, 2002, 09:11:11 AM
Polymorphism is a big OO concept, manoj. You should find a good intro to that.
- taubz
Posted by unknown_lamer [send private reply] at August 26, 2002, 02:18:05 PM
NeXT invented Objective-C for the NeXT system...it is basically C + object and nothing else. _Much_ lighter weight than C++. The object stuff is used a lot like in smalltalk and much more is done at runtime than in C++. My biggest problem with it is that it doesn't do overloading and you can only do single inheritance. The GNU Project is now reimplementing the entire NeXTSTEP/OpenSTEP/MacOSX API @ http://www.gnustep.org . You can compile a large number of old NeXTSTEP apps and OS X apps now (the non-gui part of GNUStep is past 1.0), but the GUI package needs some work (it is at version 0.8). If I still liked C a lot I might be using Objective-C now (but Scheme is better...)
Posted by manoj [send private reply] at August 26, 2002, 06:23:23 PM
Psion : I didn't pay attn to "At compile time". Got it now.
Posted by DragonWolf [send private reply] at August 27, 2002, 04:37:07 PM
polymorphism means that two functions can have the same name but receive different parameters (i.e. myfunction(int myInt) and myFunction(char myChar) is valid)
static means that the item is part of the class not the object.. so static polymorphism simply means that the class functions are part of the class (and not part of instances (objects) that are made with the class) and can contain polymorphic functions. Hope that makes sense, For those None OO for you. Class defines objects (i.e. a box) you can then create an instance (object) of that class.. i.e. create several Boxes then colour one blue, one red, etc.) Static means that it effects the entire class.. So if colour is a static variable and I tell it to change to red(then I would change the colour of all the boxes to red)
Posted by Psion [send private reply] at August 27, 2002, 05:01:43 PM
Polymorphism might mean only that in C++, but not in general.
Posted by unknown_lamer [send private reply] at August 27, 2002, 06:01:02 PM
What you are thinking of is overloading. Not much to do with polymorphism.
Posted by DragonWolf [send private reply] at August 28, 2002, 07:06:41 AM
Psion: I was talking in terms of Java
Posted by DragonWolf [send private reply] at August 28, 2002, 07:07:54 AM
Overloading is when a function is replaced by a higher function, polymorphism is two different functions distinguished by their parameters.
I'm talking Java not C/C++ though ^^
Posted by DragonWolf [send private reply] at August 28, 2002, 07:16:30 AM
ah your right about the polymorphism ^^
I've been misguided, had a stupid Java teacher.. Soz ^^
Posted by manoj [send private reply] at August 28, 2002, 09:13:05 AM
DragonWolf : "Replacing" a func by a higher/derived class' func means overriding. Overloading refers to selecting the right func out of many by arguments. And finally polymorphism (many-forms) refers to both (not only overloading).
I didn't know that static members could be overloaded/overridden in java. This is the second definition of static polymorphism. The first one by balpeck was that polymorphism in overloaded functions is the static one. Are both correct? Also is there something more about polymorphism besides (over-loading/riding) or even the def above is correct or not (all c++/java books I have give this)? If so, plz tell or give some link where I can find the definition. By the way what is ^^?
Posted by taubz [send private reply] at August 28, 2002, 03:01:11 PM
So the conclusion here is that the term "static polymorphism" has no real meaning. In the context of Java (and I think in general), methods aren't said to be polymorphic. Classes are polymorphic. So, saying a "static polymorphic" method/function still has no meaning.
In Java, static methods may be overloaded (multiple methods with the same name, but with different parameters) just like any other method. - taubz
Register as a new user | ||||||||||||||||||||||||||||