I used to own the C++ Primer 4th Edition which stated that definitions should not appear in headers. But the new edition has this:
1 2 3 4 5 6 7 8 9
|
#ifndef SALES_DATA_H
#define SALES_DATA_H
#include <string>
struct Sales_data {
std::string bookNo;
unsigned units_sold = 0;
double revenue = 0.0;
};
#endif
|
There are definitions in the header( units_sold = 0 ). So is this contradictory information?
Last edited on
> So what is the difference between default member initialisers and normal definitons?
1.
2. Only a
brace-or-equal-initialiser is accepted as a
default member initialiser
Last edited on