default values for class members
Is it possible to set a class member to a default value? I know the answer is "yes", in general, but I seem to be having trouble doing it.
Here is a truncated version of what I'm working with.
1 2 3 4 5 6 7 8 9 10 11 12 13
|
class Report
{
public:
typedef boost::shared_ptr<Report> pointer;
virtual ~Report() {}
void generate(std::ostream& output);
private:
// Write Header flag
bool printHeader;
};
|
How do I set
printHeader
to have a default value of
true
?
Write a default constructor that initializes it to true.
1 2 3 4 5
|
class Report
{
public:
Report() : printHeader( true ) {}
};
|
Much thanks! I was trying to do that earlier but must have had incorrect syntax.
Topic archived. No new replies allowed.