473,500 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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 2014
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
3043
by: Mysooru | last post by:
Hi All, One of the ATL class..... template <class Base> class CComObject : public Base { public: typedef Base _BaseClass;
2
2730
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
7809
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
4016
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
2677
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
4841
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
1433
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
3269
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
3723
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
7136
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.