[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[LC++]Question about ctors and dtors



See the following code. When run, the output is only for the test()
member. There is no output for the ctor and dtor. Why? Surely an object
of the bogus class is being created?

Paul

================================ code ============================

#include <vector>

class bogus
{
private:
	int x;
public:
	bogus();
	~bogus();
	void test();
};

bogus::bogus()
{
	cout << "constructing bogus" << endl;
}

bogus::~bogus()
{
	cout << "deconstructing bogus" << endl;
}

void bogus::test()
{
	cout << "this is a test of bogus" << endl;
}

int main()
{
	vector<bogus> mv;
	mv[0].test();
	return 0;
}