While we create a copy constructor Is this code coreect or wrong?
class a
{
public:
a(a &b)
{}
}
Printable View
While we create a copy constructor Is this code coreect or wrong?
class a
{
public:
a(a &b)
{}
}
It should be like ::
class a
{
public:
a(const a &b)
{}
}
[QUOTE=manoj200724;22231]While we create a copy constructor Is this code coreect or wrong?
class a
{
public:
a(a &b)
{}
}[/QUOTE]
This is absolutely correct. const is required to prevent the passing object being changed by copy constructor code.
i think its working. i will say tomorrow how it works
Copy constructor can be like this
B(const B &b)
{
//initialization
}
ur code is absolutely correct
that code is correct,but if u create a constant object then dt code is not correct,u have to write const classname&,like dt.ok,,,,,,,if u do not write const object then dt code is ok.
What ever u have written that is absolutely correct...