Hi all, I have worked on c++ for a reasonable amount of time. But i am not strong in polymorphism. Now suppose i have Code: Class SHAPE { public: Print() {///Code } } class Triangle: public SHAPE { public : Print() { } } In the above example, Triangle and SHAPE are polymorphic. But if the case is Code: Class SHAPE { public: Print() {///Code } private: int a[100]; double color; } class Triangle: public SHAPE { public : Print() { } private: int a; } Are these 2 classes still polymorphic And also if the case is Code: Class SHAPE { public: Print() {///Code } int a[100]; double color; } class Triangle: public SHAPE { public : Print() { } int a; }
The misconception about polymorphism is they can only be related to functions which comes when you read books who themeselve do not know abotu polymorphism but the real meaning of polymorphism is giving poly ( many ) usage of the same thing whether it be function / class / object / even a variable. Say if I declare an int i and then use the same int i in loops thrice then that also means polymorphism because the variable I declared was used to loop through 3 context and I know its bad programming but then its polymorphism. In your case you always have the function but if the function would have been not there then also it would have been polymorphism.
Oh ok, thanks dude. One more doubt. Is there any special case where a child class is not a polymorphic version of its base class? Is polymorphism' s basic idea up-casting and down casting? Thanks and Regards, Rohith.H.N
> Is there any special case where a child class is not a polymorphic version of its base class? Is polymorphism' s basic idea up-casting and down casting? I think you could be confusing polymorphism with inheritance. Triangle is derived from SHAPE; it inherits SHAPE's functionality and data. In themselves neither Triangle nor SHAPE are polymorphic; this is about what you do with classes. If you had another class Square also derived from SHAPE this too isn't polymormphism, although is a necessary prerequisite to it. Now suppose you have a drawing program which draws triangles and squares, using a list of type SHAPE and calling SHAPE->draw(), where draw() is defined in Triangle and Square (and SHAPE, of course, where it could either be a default draw operation or virtual void draw()=0, the latter of which would also prevent you instantiating SHAPEs). THAT is polymorphism - poly=many; morph=shape/type, not to mention the Red Dwarf episode Polymorph where a creature was able to determine its own appearance) so a pointer-to-SHAPE is being used as a pointer to many different things. Any use of a SHAPE* pointer to manipulate a Triangle or Square object would constitute polymorphism.
the doubt of polymorphism is only resolve by the practice, so do practice by reading books and practicing programs any way polymorphism is Polymorphism is the ability to use an operator or function in different ways. Polymorphism gives different meanings or functions to the operators or functions. Poly, referring to many, signifies the many uses of these operators and functions. A single function usage or an operator functioning in many ways can be called polymorphism. Polymorphism refers to codes, operations or objects that behave differently in different contexts.
Hm ... To start : lspci | grep Network If you get something like this : 03:00.0 Network controller: Broadcom Corporation BCM4322 802.11a/b/g (rev 02) You need to use ndiswrapper for install drivers. But 1st,as we know this is Debian platform now and i think that u can try this : sudo apt-get install b43-fwcutter If you get some message after install just click ok.
Polymorphism : Polymorphisms is a generic term that means 'many shapes'. More precisely Polymorphisms means the ability to request that the same operations be performed by a wide range of different types of things.