K
kirk_korver
Group,
I'm trying to understand the problem with the following code. The
problem I get is associated with the line "int fmt = format(); " at
the bottom of the line. The error I get says that "format does not
take 0 arguments". It appears that the version of "format" that
returns an INT is NOT available to a derived class. Please notice that
there are 2 version of the format function.
Is this correct behavior? I get the same error with both the g++ and
the MSVC compilers.
Any help would be much appreciated.
--Kirk
<code>
class Parent {
public:
int format() { return m_format; }
int m_format;
};
class Child : public Parent {
public:
bool format(int fmt);
void foo();
};
bool Child::format(int frmt) {
m_format = frmt;
return true;
}
void Child::foo() {
format(3);
int fmt = format();
}
</code>
I'm trying to understand the problem with the following code. The
problem I get is associated with the line "int fmt = format(); " at
the bottom of the line. The error I get says that "format does not
take 0 arguments". It appears that the version of "format" that
returns an INT is NOT available to a derived class. Please notice that
there are 2 version of the format function.
Is this correct behavior? I get the same error with both the g++ and
the MSVC compilers.
Any help would be much appreciated.
--Kirk
<code>
class Parent {
public:
int format() { return m_format; }
int m_format;
};
class Child : public Parent {
public:
bool format(int fmt);
void foo();
};
bool Child::format(int frmt) {
m_format = frmt;
return true;
}
void Child::foo() {
format(3);
int fmt = format();
}
</code>