472,354 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

"can't convert parameter" error

// 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
3 1947
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mysooru | last post by:
Hi All, One of the ATL class..... template <class Base> class CComObject : public Base { public: typedef Base _BaseClass;
2
by: John A Grandy | last post by:
Is there something special in XML about the name "Parameter" ... I am not able to XPATH query for nodes named "Parameter" <Root> <Category CategoryID="1"> <Elements> <Element...
40
by: Dave Hansen | last post by:
Please note crosspost. Often when writing code requiring function pointers, it is necessary to write functions that ignore their formal parameters. For example, a state machine function might...
4
by: Ondrej Spanel | last post by:
The code below does not compile with .NET 2003, I get folowing error: w:\c\Pokusy\delegTemplArg\delegTemplArg.cpp(11) : error C2993: 'float' : illegal type for non-type template parameter 'x' ...
1
by: sd | last post by:
QUESTION: How can my ASP page - which uses language="VBScript" - pass a "System.Collections.ArrayList" object - as a parameter - to a C# method in the middle-tier ??? ----- Is it possible at...
15
by: jjh | last post by:
So with infile I have this so far: #define MAXBOOKS 9 ifstream infile("library.txt"); struct Book { title } while(true) {
2
by: Nemisis | last post by:
Hi, Is it possible to pass in an object and parameter into a function and return it as a string. i.e. To make a call to the function i would put the following Dim str as String =...
4
by: =?utf-8?B?Qm9yaXMgRHXFoWVr?= | last post by:
Hello, what is the use-case of parameter "start" in string's "endswith" method? Consider the following minimal example: a = "testing" suffix="ing" a.endswith(suffix, 2) Significance of...
4
by: thyagi | last post by:
a function which takes a string (pointer to char) as a parameter and returns the integer equivalent.str2int("1658") would return the value 1658 To improve your program change the function to accept...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.