# why constructor cannot be virtual

**URL:** <https://community.unix.com/t/why-constructor-cannot-be-virtual/173869>\
**Category:** Programming\
**Created:** [August 3, 2007, 12:29am UTC](https://community.unix.com/t/why-constructor-cannot-be-virtual/173869 "2007-08-03T00:29:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amitpansuria](https://community.unix.com/letter_avatar/amitpansuria/32/6_22734026db12803ebb3e059622ac3534.png) [@amitpansuria](https://community.unix.com/u/amitpansuria)\
**Post date:** [August 3, 2007, 12:29am UTC](https://community.unix.com/t/why-constructor-cannot-be-virtual/173869/1 "2007-08-03T00:29:58Z")

</div>

helo i read many books but i cant find the proper answer that why  
constructor cannot be virtual  
can u explain me in simple term that why constructor cannot be virtual  
Regards,  
Amit

---

<div class="post-metadata">

**Author:** ![andryk](https://community.unix.com/user_avatar/community.unix.com/andryk/32/101_2.png) [@andryk](https://community.unix.com/u/andryk)\
**Post date:** [August 3, 2007, 2:21am UTC](https://community.unix.com/t/why-constructor-cannot-be-virtual/173869/2 "2007-08-03T02:21:59Z")

</div>

Because some properties of a virtual function does not apply to constructor such as "run time binding", besides why would you want a virtual constructor ???

---

<div class="post-metadata">

**Author:** ![porter](https://community.unix.com/letter_avatar/porter/32/6_22734026db12803ebb3e059622ac3534.png) [@porter](https://community.unix.com/u/porter)\
**Post date:** [August 3, 2007, 3:02am UTC](https://community.unix.com/t/why-constructor-cannot-be-virtual/173869/3 "2007-08-03T03:02:17Z")

</div>

> [@amitpansuria](#):
>
> can u explain me in simple term that why constructor cannot be virtual

Virtual works by the object pointing to a v-table, and the caller dereferencing the call via the v-table. Immediately prior to construction time you don't have an object which points to a vtable to make the call.

Solutions to this include using factory objects, which is exactly what COM does with IClassFactory so the call to CreateInstance is virtual. Similarly IBM's SOMClass::somNew.
