Possible Duplicate:
Why is there no call to the constructor?
Please have a look at the following code
UIHandler.h
#pragma once
class UIHandler
{
public:
UIHandler();
~UIHandler(void);
private:
//Book *books;
};
UIHandler.cpp
#include "UIHandler.h"
#include <iostream>
using namespace std;
UIHandler::UIHandler()
{
{
//action once code goes here
}
int selection;
cout << "..............Welcome to DigitalLab Library..........." << endl << endl;;
cout << "Kindly press, " << endl;
cout << "1. Enter Books" << endl;
cout << "2. Display Books"<< endl;
cout << "3. Member Area" << endl;
cout << "Your Selection: ";
cin >> selection;
}
UIHandler::~UIHandler(void)
{
}
Main.cpp
#include <iostream>
#include "UIHandler.h"
using namespace std;
int main()
{
UIHandler a();
system("pause");
return 0;
}
In this code, I am unable to execute the constructor in UIHandler, because the code runs but nothing happens. If I pass a parameter to the UIHandler constructor, it works as it should be, even I take no use of the constructor. Why is that? Please help!