/*Orion Lawlor's Simple C++ Examples, olawlor@acm.org
Shows how to use various constructor types.
*/
#include <iostream>

class foo {
public:
	//The no-argument (default) constructor
	foo(void) {std::cout<<"foo default constructor"<<std::endl;}
	
	//A single-argument (conversion) constructor
	foo(int x) {std::cout<<"foo constructor("<<x<<")"<<std::endl;}
	
	//A copy constructor
	foo(const foo &other) {std::cout<<"foo copy constructor"<<std::endl;}
};

void A(foo f) //<- should probably be "foo& f"!  Beware!
{}

int main()
{
	foo a;
	foo *ap=new foo;
	delete ap;
	
	foo b(2);
	foo *bp=new foo(2);
	delete bp;
	
	foo c(b);//Copy constructor
	
	A(c); //Copy constructor again!
	A(2); //Conversion constructor!
	
	return 0;
}
/*<@>
<@> ******** Program output: ********
<@> foo default constructor
<@> foo default constructor
<@> foo constructor(2)
<@> foo constructor(2)
<@> foo copy constructor
<@> foo copy constructor
<@> foo constructor(2)
<@> */
