D
Dave C
I've written the following code that won't compile, trimmed down to
just the pertinent stuff:
--- WindowClass.hxx ----------------------------------------------------
#include <set>
class Window;
class WindowClass {
public:
addWindow (Window const* const window);
private:
static std::set<Window*> s_constructing;
};
------------------------------------------------------------------------
--- WindowClass.cxx ----------------------------------------------------
#include "WindowClass.hxx"
using namespace std;
void WindowClass::addWindow (Window const* const window) {
if (s_constructing.count(window) > 0) {
<snip>
}
}
------------------------------------------------------------------------
The error I get is on the line:
if (s_constructing.count(window) > 0) {
The compiler tells me that there's no match for my call to .count, but
it has a near match const function. The thing I don't understand is,
why wouldn't my non-const function call a const function. I know it
won't work the other way around, but that's not what I'm trying to do.
I can get it to compile if I remove const from addWindow()'s
parameter, but I want to make this const correct. Can anyone enlighten
me?
just the pertinent stuff:
--- WindowClass.hxx ----------------------------------------------------
#include <set>
class Window;
class WindowClass {
public:
addWindow (Window const* const window);
private:
static std::set<Window*> s_constructing;
};
------------------------------------------------------------------------
--- WindowClass.cxx ----------------------------------------------------
#include "WindowClass.hxx"
using namespace std;
void WindowClass::addWindow (Window const* const window) {
if (s_constructing.count(window) > 0) {
<snip>
}
}
------------------------------------------------------------------------
The error I get is on the line:
if (s_constructing.count(window) > 0) {
The compiler tells me that there's no match for my call to .count, but
it has a near match const function. The thing I don't understand is,
why wouldn't my non-const function call a const function. I know it
won't work the other way around, but that's not what I'm trying to do.
I can get it to compile if I remove const from addWindow()'s
parameter, but I want to make this const correct. Can anyone enlighten
me?