Dj MuNgAs!
Old Skool
- Joined
- Aug 12, 2004
- Messages
- 9
- Gender
- Undisclosed
- HSC
- N/A
What are some ways in which you can study the notes for sdd? Does anybody know how to do pseudocode properly as well? any links to help us out with that problem?
Thats not polymorphism at all; it's just function overloading.PoP 'n' Fresh said:li0n, get your hands on some java or c++ code, plenty of examples there.
the easiest i can think of for polymorphism is method (or function) overloading. i.e:
function addAmount(Integer num1, Integer num2) {
add num1 and num2
}
function addAmount(Double num1, Double num2) {
add num1 and num2
}
there ya go. polymorphism =)
oh, and thats just one form of polymorphism... it gets confusing, keep it at that =)
class A
{
public:
virtual int foo ( ) { return 10; }
};
class B : public A
{
public:
virtual int foo() { return 20; }
};
// This is polymorphism, base class pointer pointing to derived class
A* b = new B();
// Bam, virtual function table gets looked up and B::foo gets called returning 20
int result = b->foo();
delete b;
Overloading is a form of polymorphism. The most common form of polymorphism is what you have described - this is referred to as subtyping polymorphism (aka inheritance in C++ and Java). Another form of polymorphism is ad hoc polymorphism - overloading. In this case we would say the function is polymorphic, not the object itself.string2004 said:Thats not polymorphism at all; it's just function overloading.