|
hi friends in MICROSOFT interview i have faced a question why abstract base class is needed? with out any instantiation what is its use ?
I tried to answer for it like its for design perspective,what r the behaviours
(virtual functions)specified in the Abstractbase class can be elaborated in the derived classes...like that the main purpose is its used as interface....
like that ,But he is not satisfied with my answer.
So Any of u can make my answer value added ?
krishna
|
|
|
|
|
It is usefull for polymorphism to provide a uniform way to manage different objects. They all have the same 'interface' but provide different behavior which are coded it the derived classes.
|
|
|
|
|
I doubt that, what is necessity of pure virtual functions?
- NS -
|
|
|
|
|
To force the redefinition in derived class. It is just to protect reusability of the code. It is used so that you (or other developers that will reuse your code) don't 'forget' to provide a definition of a function which is required.
|
|
|
|
|
Yes... I understood. Thank you
- NS -
|
|
|
|
|
hai, can u make more sense ?
|
|
|
|
|
Some quick points
- Abstract Factory Design Pattern
- Code reusability
- Interface driven approach of programming
- Polymorphism
S o h a i l K a d i w a l a
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Code reusability:
how is it possible there is no code to reuse in Abstract base classes
|
|
|
|
|
Krishnatv wrote: how is it possible there is no code to reuse in Abstract base classes
It's not the base class or its existing derivatives in this case that is being "reused".
It's the code that uses the existing derivatives, the calling code (client?).
At least in theory, in practice it depends on whether the design is good or bad.
The use of abstract factories could leave the calling code unchanged if implemented properly.
--
Rog
It's suppose to be hard, otherwise anybody could do it!
|
|
|
|
|
Hi Friend,
Is there any API which convert int(int a) to basic string(string b)?
itoa can convert a(int) to char*(Char *c) and I can get b from c.However is there any other way?
Thanks
|
|
|
|
|
wsprintf(str,"%d",n) is another way
- NS -
|
|
|
|
|
I think he was asking how to convert an integer into a std::string directly
|
|
|
|
|
|
Sorry I am not familar with that...
- NS -
|
|
|
|
|
Yes but that's not a direct conversion. He was asking for a direct conversion, without using a char array.
Something like Format in CString.
Unfortunately I don't know if this is possible.
|
|
|
|
|
this is not possible, because basic_string is at first a template, so for whatever kind of type...
|
|
|
|
|
sorry buddy, i really don't understand your question.
will you please rephrase ?
|
|
|
|
|
some times, its because ur from another planet
nave
|
|
|
|
|
what do you mean?
- NS -
|
|
|
|
|
remember the discussion below[^]
|
|
|
|
|
don't u know v2.0 is from another planet(An alien with vc++ knowledge)
nave
|
|
|
|
|
he might have jump over the post
but now, it's cool, anybody knows... :->
|
|
|
|
|
but what did you do to my thread ?!
|
|
|
|
|
sorry don't attack my earth for my mistake...Please
nave
|
|
|
|
|
If he do so we can pause him... He is providing C:\> prompt... Just type "pause" command there...
- NS -
|
|
|
|