473,837 Members | 1,693 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 2031
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
3070
by: Mysooru | last post by:
Hi All, One of the ATL class..... template <class Base> class CComObject : public Base { public: typedef Base _BaseClass;
2
2762
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 ElementID="1"></Element> <Element ElementID="2"></Element> <Element ElementID="3"></Element> </Elements>
40
7916
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 take a status input, but a certain error-handling state might ignore it: typedef void (*State_Fn)(uint8_t); void error_state(uint8_t status)
4
4039
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' The error shows compiler is quite confused - x is not a template parameter at all. I have found two workarounds, but still I think the code should compile.
1
2696
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 all? - if not, what work-a-round is there? I have no issues passing "string" parameters successfully to other methods in the same "middle-tier" - i.e., C# - object... It just seems to be the "ArrayList" parameter that is at issue.
15
4881
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
1461
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 = MyTestFunction(myObject.Parameter)
4
3310
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 "end" is obvious. But not so for "start".
4
3747
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 strings with a leading minus sign toi ndicate a negative number. One last improvement might be to print a warning if the string represents a numberthat is outside the range of an int.
0
9830
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9682
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10263
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9390
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7803
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5842
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4469
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3122
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.