Question: We can call destructor explicitly through class pointer, why not constructor? Any idea?

```
#include <iostream>

class Con {
public:
    Con( int x ) : x( x ) {

    }

private:
    int x;
};

int main() {
    Con* c = new Con( 1 );
    //c->Con( 2 ); //illegal
    c->~Con(); // ok!
    delete c;
}

```

Thanks,

Answer: 
A Constructor's intent is to be called when the object is created. Nothing else. If you had a reference counter to keep track of the number of objects, allowing the constructor to be called as a function would mess the counter up.

If you want to reinitialize or reset an object, you can add a function called Reset() or Initialize() and call it from the constructor. Then, you can also call Reset() or Initialize() from an object pointer.
Ofc you can call it from an object instance , see this code :

```
 #include <iostream>
class foo{
      public :
      int foo_var;
      foo(){
            std::cout<<"foo_var = "<<foo_var<<std::endl;
            }
      };
int main()
{
    foo * f = new foo();
    // set foo_var
    f->foo_var = 10;
    // call constructor by passing object instanse
    foo * f1 = new(f) foo;
    std::cout<<(f==f1)<<std::endl;
    system("pause");
    return 0;
}

```

the second output is "foo\_var = 10" so it is working . the third output is "true" then (f==f1) that mean the constructor does not allocate new memory (the operator new does , but we passed a pointer to it so he wont alloc an other) 
there you are a really usefull practice : 

```
#include <iostream>
template <class t>
class smart_pointer{
      t * p; // the real normal pointer
      public :
      smart_pointer()
      {
          p = (t*) malloc(sizeof(t)); // allocate memory 
          try{ 
          new (p) t; // call the constructor 
          } catch (...)  // if it throws any exception
          {
                  free(p); // free p , dont use delete , because it will
                  // call the destroctor calling the destructor will cause 
                  // freeing a not allocated memory that causes a crash
                  throw; // throw the exception what ever it was
          }

      }
      ~smart_pointer(){delete p;}
      t operator = (t val) // assigment operator
      {
               *p = val;
               return val;
      }
      operator t(){ // type casting operator , usually for std::cout
               return *p;
               }
      };
int main()
{
    smart_pointer<int> x;
    x = 10;
    std::cout<<x<<std::endl;
    system("pause");
    return 0;
}

```

it is recommended to read "effective c++" , "more effective c++" , "effective modern c++" books