By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,426 Members | 1,729 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,426 IT Pros & Developers. It's quick & easy.

"can't convert parameter" error

P: n/a
// why is the error message being generated?
// Microsoft Visual C/C++ 5.0

class Bar
{
public:
void Log(const char* p){ }
};

class Foo : public Bar
{
public:
void Log(int x){ }
};

int main()
{
Foo foo;
foo.Log("foo bar"); // error message below

return(0);
}

// error C2664: 'Log' : cannot convert parameter 1 from 'char [8]' to 'int'

Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Ian Lazarus wrote:
// why is the error message being generated?
// Microsoft Visual C/C++ 5.0

class Bar
{
public:
void Log(const char* p){ }
};

class Foo : public Bar
{
public:
using Bar::Log;
void Log(int x){ }
};

int main()
{
Foo foo;
foo.Log("foo bar"); // error message below

return(0);
}

// error C2664: 'Log' : cannot convert parameter 1 from 'char [8]' to
'int'


Bar::Log hides Foo:Log as a name.

--
WW aka Attila
:::
'Meesa Jar Jar Binks of Borg! Yousa gonna be Assim'lated!'
Jul 22 '05 #2

P: n/a
White Wolf wrote:

Bar::Log hides Foo:Log as a name.


Ehem, the other way around

--
WW aka Attila
:::
When all you have is a hammer, the whole world looks like a nail.
Jul 22 '05 #3

P: n/a
On Sat, 31 Jan 2004 21:54:56 GMT, "Ian Lazarus" <no****@nowhere.net>
wrote:

// why is the error message being generated?
// Microsoft Visual C/C++ 5.0

class Bar
{
public:
void Log(const char* p){ }
};

class Foo : public Bar
{
public:
void Log(int x){ }
};

int main()
{
Foo foo;
foo.Log("foo bar"); // error message below

return(0);
}

// error C2664: 'Log' : cannot convert parameter 1 from 'char [8]' to 'int'

Hi,

this error is created, because the "Log" method of your class "Foo"
takes an integer as parameter.
"Foo" inherets the Log function from Bar but you overwrite it in Foo
so it's parameter isn't a "const char *" anymore but your "int x".

Olli
Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.