Question regarding assignment operator and copy constructor

Hi all, I have few basic questions here. Consider the following class :
class Test {
int a;
}

What is auto generated here by the compiler ?
I think it's the default constructor and the default destructor.

And are some default copy constructor and assignment operator generated also, or we'll have to declare them explicitly ?

Another question, if we define our own constructor, there will be no default constructor generated by the compiler, am I right ?

Thank you

p.p.:
My opinion is that there is auto generated default constructor, destructor and assignment operator, but only if there are no explicitly defined such. I want to know am I right here. :)
Last edited on
And are some default copy constructor and assignment operator generated also, or we'll have to declare them explicitly ?
There is just one copy constructor and if you don't declare yours the compiler would generate one, it will also make for you an assignment operator
Another question, if we define our own constructor, there will be no default constructor generated by the compiler, am I right ?
Yes
So I understand that there will be a copy constructor generated after all. And assignment operator.
And I guess of course default constructor (with no arguments) and destructor also :

OurClass(&AnotherClass instance); // copy constructor
OurClass(); // default constructor
~OurClass(); // default destructor
// and also assignment operator here


Thank you for your answer, Bazzy.
Copy constructor is like this:
OurClass(const OurClass &instance);
Yes, of course.
Topic archived. No new replies allowed.