R
Ray
Hi all,
After many years of C, I thought I'd move to C++ recently. I think
because I think in C, I'm coming to a misunderstanding of something.
I've created a class foo which contains a private variable which is a
priority queue. In class foo's header file, I declared it as:
class foo {
private:
unsigned int count;
priority_queue<double, std::vector<double>, greater<double> >
pqueue;
};
In the constructor, I'm being warned that I should initialize in the
member initialization list (as I am new, I added all these warnings to
my compiler). So, I know I could do:
foo::foo ()
: count (0)
{
}
but now I'm stuck. How does one initialize a priority queue? I want
to have a priority queue with nothing (i.e., empty) and it's already
done that for me in the declaration (I think...). Did I just get
myself in trouble by turning on the warnings and I should just ignore
this one about initializing pqueue? Obviously, this isn't an error
and I can continue...but I would like to know what should I do...
Thanks!
Ray
After many years of C, I thought I'd move to C++ recently. I think
because I think in C, I'm coming to a misunderstanding of something.
I've created a class foo which contains a private variable which is a
priority queue. In class foo's header file, I declared it as:
class foo {
private:
unsigned int count;
priority_queue<double, std::vector<double>, greater<double> >
pqueue;
};
In the constructor, I'm being warned that I should initialize in the
member initialization list (as I am new, I added all these warnings to
my compiler). So, I know I could do:
foo::foo ()
: count (0)
{
}
but now I'm stuck. How does one initialize a priority queue? I want
to have a priority queue with nothing (i.e., empty) and it's already
done that for me in the declaration (I think...). Did I just get
myself in trouble by turning on the warnings and I should just ignore
this one about initializing pqueue? Obviously, this isn't an error
and I can continue...but I would like to know what should I do...
Thanks!
Ray