C++ Programming - OOPS Concepts - Discussion

Discussion Forum : OOPS Concepts - General Questions (Q.No. 18)
18.
Which of the following correctly describes overloading of functions?
Virtual polymorphism
Transient polymorphism
Ad-hoc polymorphism
Pseudo polymorphism
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
36 comments Page 1 of 4.

Vicky said:   1 decade ago
What is meant by Ad-hoc polymorphism, transient and psuedo polymorphism?

Varsha said:   1 decade ago
What is meant by Ad-hoc polymorphism, transient and psuedo polymorphism.

Aniket said:   1 decade ago
Ad-hoc polymorphism allows functions with the same name act differently for each type. For example, given two ints and the + operator, it adds them together. Given two std::strings it concatenates them together. This is called overloading.

Here is a concrete example that implements function add for ints and strings,

#include <iostream>
#include <string>

int add(int a, int b) {
return a + b;
}

std::string add(const char *a, const char *b) {
std::string result(a);
result += b;
return result;
}

int main() {
std::cout << add(5, 9) << std::endl;
std::cout << add("hello ", "world") << std::endl;
}
Ad-hoc polymorphism also appears in C++ if you specialize templates. Returning to the previous example about max function, here is how you'd write a max for two char *,

template <>
const char *max(const char *a, const char *b) {
return strcmp(a, b) > 0 ? a : b;
}

Sanil said:   1 decade ago
Can anyone explain more about Ad-hoc polymorphism, transient and psuedo polymorphism ?

Rupali said:   1 decade ago
What is mean by transient and pseudo polymorphism ?

Kalpana said:   1 decade ago
What is transient and pseudo polymorphism ? and it is a type polymorphism ? then explain more about Ad-hoc polymorphism ?

Shweta said:   1 decade ago
In programming languages, ad-hoc polymorphism is a kind of polymorphism in which polymorphic functions can be applied to arguments of different types, because a polymorphic function can denote a number of distinct and potentially heterogeneous implementations depending on the type of argument(s) to which it is applied. It is also known as function overloading or operator overloading.

Pavithra said:   1 decade ago
Ad-hoc polymorphism behaves differently for different data types with same name.

Can anyone explain about pseudo polymorphism and transient polymorphism?

Supreet kaur said:   1 decade ago
Is Ad-hoc polymorphism and overloading is the same thing?

Shivajiswaraj said:   1 decade ago
Ad hoc polymorphism allows to funtion overloading.


Post your comments here:

Your comments will be displayed after verification.