do I need to specify an = operator for this

G

Gernot Frisch

class A
{
struct DATA
{
std::vector<std::string> descriptions, units;
std::vector<double> values;
std::string type, name;
} elalin;
}

Do I need to explicitly write an = operator for 'A' and/or for 'DATA'
?
The operator should call the '=' operator for each member.

Thank you,
 
R

Rolf Magnus

Gernot said:
class A
{
struct DATA
{
std::vector<std::string> descriptions, units;
std::vector<double> values;
std::string type, name;
} elalin;
}
;

Do I need to explicitly write an = operator for 'A' and/or for 'DATA'
?
No.

The operator should call the '=' operator for each member.

Yes, it should.
 
K

Karl Heinz Buchegger

Gernot said:
class A
{
struct DATA
{
std::vector<std::string> descriptions, units;
std::vector<double> values;
std::string type, name;
} elalin;
}

Do I need to explicitly write an = operator for 'A' and/or for 'DATA'
?
The operator should call the '=' operator for each member.

If this is all your op= needs to do, then no, yo udon't need
to write one yourself. The compiler generated one will do
exactly that:
call op= for the base classes (if they exists)
call op= for all members
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,652
Latest member
Campbellamy

Latest Threads

Top