Reputation: 31
class exemple{
const int a
exemple(exemplec const &item){
}
};
I need to make a copy constructor for a project with a const attribute, I don't have a cloue how to make it.
Upvotes: 0
Views: 129
Reputation: 56479
Do as below, make the copy-constructor public, fix a typo, copy the member's value.
class exemple
{
const int a;
public:
exemple(exemple const &item) : a(item.a) {}
};
You can initialize constant member using initializer list like the code.
Upvotes: 2