That is the destructor, not a constructor.
1. If you provide a declaration of a constructor or a destructor you need to implement them, if you don't provide a declaration the compiler would provide the default ones
2. A destructor doesn't take arguments
1) your original example with the apple was a destructor. Simply the name of the class with a ~ before it.
2) constructors that don't take any arguments (or whose arguments all have default values) are "default constructors". They are used when no arguments are supplied for the constructor.
3) you don't need the 'void' in there. That's a carryover from C. orange() is the same as orange(void) in this case.
// an example class
class Test
{
public:
Test()
{
cout << "default ctor called\n";
}
Test(int v)
{
cout << "ctor called with v=" << v << "\n";
}
~Test()
{
cout << "dtor called\n";
}
};
void func()
{
Test a[3]; // calls default ctor 3 times
Test b; // calls default ctor once
Test c(4); // calls 'int v' ctor with v=4
} // end of function, objects lose scope/die. calls the dtor for each object (5 times total)