*
:
>
> class abstractclass
> {
> public:
> abstractclass(){}
> virtual void method()=0;
> };
>
> class concreteclass
ublic abstractclass
> {
> public:
> concreteclass(){}
> void method(){}
> };
>
> void main()
> {
>
> concreteclass c;
> }
'main' must have result type 'int'.
If your compiler accepts the above, then it's non-conforming in this
respect.
> now when I create the object of concreteclass, the constructor of
> abstractclass will be called.and as per the logic constructors are
> called while creating the object,object of abstractclass is being
> created..so how come we can create an object of a abstract class?
> or to put in another way is there any paradox when the constructor of
> an abstract class gets called?
The reason C++ forbids you to instantiate an abstract class on its own
is that it's not meaningful: an abstract class _depends_ on its pure
virtual functions to do the crucial things (that's why it's abstract).
As a base class part of another object those pure virtual functions are
defined, by the derived class, i.e. you have totally different
situation, and that's the whole point, the way it's meant to be used.
However, there is a possibility of erronously calling a pure virtual
function from the abstract class constructor, via some other member
function. The result of that is undefined behavior, but most likely it
will be detected and cause a crash. It simply means that static
(compile-time) type checking and rules based on such checking can not
protect against all run-time errors, which we knew anyway.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
[ See
http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]