M
moleskyca1
Hi,
In a recent discussion, some of us were in disagreement about the
functions the C++ compiler generates. How many functions are generated
by the compiler when you declare:
class Foo
{
}; ?
I thought 4. As in:
class Foo
{
public:
Foo(); // default constructor
Foo(const Foo& f); // default copy constructor
~Foo(); // default destructor
Foo &operator(const Foo& f); // default assigment operator
};
Is this list correct? Is that all?
Someone said you must also add the new and delete operators, so that's
6. I have not read the standard, but I'd argue that if this is so, then
you should also count operator* () and operator& ()
In a recent discussion, some of us were in disagreement about the
functions the C++ compiler generates. How many functions are generated
by the compiler when you declare:
class Foo
{
}; ?
I thought 4. As in:
class Foo
{
public:
Foo(); // default constructor
Foo(const Foo& f); // default copy constructor
~Foo(); // default destructor
Foo &operator(const Foo& f); // default assigment operator
};
Is this list correct? Is that all?
Someone said you must also add the new and delete operators, so that's
6. I have not read the standard, but I'd argue that if this is so, then
you should also count operator* () and operator& ()