473,322 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Why compilation error here?

Hi all!

Example here doesn't compile in both VC++ and gcc. It's like Get(int&)
somehow hides Get() in CDerived. Does anybody has an idea why?

class CBase
{
public:
int Get() const { int i; Get(i); return i;};
virtual bool Get(int& i) const { return false; }
};

class CDerived : public CBase
{
int j;
public:
virtual bool Get(int& i) const { i = j; return true; }
};

void WTF()
{
CDerived d;
int test = d.Get(); // error 2660: function does not take 0 arguments
// int test = d.CBase::Get(); works, but yuck!

CBase b;
test = b.Get(); // OK.
}
Thanks,
Goran,

Sep 12 '06 #1
2 2072
Goran wrote:
Hi all!

Example here doesn't compile in both VC++ and gcc. It's like Get(int&)
somehow hides Get() in CDerived. Does anybody has an idea why?

class CBase
{
public:
int Get() const { int i; Get(i); return i;};
virtual bool Get(int& i) const { return false; }
};

class CDerived : public CBase
{
int j;
public:
virtual bool Get(int& i) const { i = j; return true; }
};

void WTF()
{
CDerived d;
int test = d.Get(); // error 2660: function does not take 0 arguments
// int test = d.CBase::Get(); works, but yuck!

CBase b;
test = b.Get(); // OK.
}
Thanks,
Goran,
I'm not sure but I think when you redefine Get in CDerived for int
parameter, you're hiding Get().
I think it's due to:
http://www.parashift.com/c++-faq-lit....html#faq-23.9
Sep 12 '06 #2

Goran wrote:
Hi all!

Example here doesn't compile in both VC++ and gcc. It's like Get(int&)
somehow hides Get() in CDerived.
It's like Get(int&) somehow hides Get() because that's exactly what
does happen.
Does anybody has an idea why?
Why is because that's what the language rules say. This section of the
FAQ

http://www.parashift.com/c++-faq-lit...heritance.html

should show you ways round the problem.

<snip code>

Gavin Deane

Sep 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: tuko | last post by:
Hello kind people. The folliowing code gives me a compilation error, under MSVC 6.0 and intel 8.0 compiler. It compiles fine with g++ 3.3.1 and borland 5.5 Can you tell me please if the code...
4
by: Ced | last post by:
Hi, i'm not an expert in C but i try to compile BTNG software under linux kernel 2.4.2-2. I get these errors at the very first stage. Does someone could have a rapid look on this and tell me...
10
by: Sune | last post by:
Hi, previously I used Eclipse CDT for compiling my files just to get started with C and leave C++ behind. Now it's time to get a little more serious so I've moved my files to a new workplace and...
2
by: FireStarter | last post by:
Guys, in the code that follows, why does the method F() still compile, even if DBG is undefined? Inside method G(), the code inside <#if DBG> does not compile (notice that I can write whatever I...
5
by: Raterus | last post by:
I'm just throwing this error out for my sanity, I've seen posts about this, but never solutions. I'm using VS.NET 2003, Framework 1.1, and I'm getting a random error about every 1 out of 10 times...
2
by: Kevin R. | last post by:
I have been ignoring this problem for a few weeks now, but it's becoming a bit annoying not to mention unproductive. Here it goes: I compile my project with no errors. Then after I debug/run it,...
6
by: Plat | last post by:
I've Googled this for a while, to no avail. Hopefully someone can help me. Maybe I'm using the wrong terminology. Here's the scoop! Let's say I've got a simple *.ASPX page that has a syntax...
10
by: RedEagle | last post by:
Hi All! Do you remember me? I am that desperate who had this error for a while: --- Compilation Error Description: An error occurred during the compilation of a resource required to service...
1
by: BSand0764 | last post by:
I'm getting an error that I can't seem to resolve. When I compile the Functor related logic in a test program, the files compile and execute properly (see Listing #1). However, when I...
1
by: Alex Vinokur | last post by:
Hi, I have compilation problem on SUN CC compiler with template while using option -m64 (64-bit addressing model). No problem while using option -m32 (32-bit addressing model) $ CC -V CC:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.