Hi,
AFAIK, a "default" copy constructor (i.e the one the compiler will implicitly generate if you didn't define your own copy constructor) will copy all non static members using their copy constructors.
But what do I do, when I have a class that has various parameters that MUST be given at initialization?
Lets say I have the following class:
{
private:
//code
};
class myClass(QString port)
{
private:
QString m_port;
//code
};
To copy to clipboard, switch view to plain text mode
now, after initialization, port will be assigned to m_port.
If I don't define my own copy constructor, then the code:
myClass A("ttyS0");
myClass B(A);
myClass A("ttyS0");
myClass B(A);
To copy to clipboard, switch view to plain text mode
will create class B with m_port == "ttyS0".
Which is a dangerous thing.
So my question is:
Is there a way for me to disable the default copy constructor?
Defining my own copy constructor is not possible, since I it need to get the port parameter from the user, and each class needs to have its own and different from the others port parameter.
Thanks.
EDIT: subject should read "Confused with copy construcotrs
Bookmarks