identical function names in and out a class can't compile



 DEVELOP > c-Plus-Plus > identical function names in and out a class can't compile

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "ciccio"
Date: 11 Jan 2008 05:48:43 AM
Object: identical function names in and out a class can't compile
Hi,
I don't know, but why is this not compiling? As far as I see there is
no ambiguity
regards
[]$ cat samename.cpp
#include <iostream>
void foo(int a, int b) {
std::cout << a+b << std::endl;
}
class bar {
void foo(int a) { foo(a,a); }
};
[]$ g++ -c samename.cpp
samename.cpp: In member function ‘void bar::foo(int)’:
samename.cpp:8: error: no matching function for call to ‘bar::foo(int&,
int&)’
samename.cpp:8: note: candidates are: void bar::foo(int)
.

User: "Ondra Holub"

Title: Re: identical function names in and out a class can't compile 11 Jan 2008 05:53:06 AM
On 11 Led, 12:48, ciccio <no_valid_em...@spam.com> wrote:

Hi,

I don't know, but why is this not compiling? As far as I see there is
no ambiguity

regards

[]$ cat samename.cpp
#include <iostream>
void foo(int a, int b) {
std::cout << a+b << std::endl;}

class bar {
void foo(int a) { foo(a,a); }

};

[]$ g++ -c samename.cpp
samename.cpp: In member function 'void bar::foo(int)':
samename.cpp:8: error: no matching function for call to 'bar::foo(int&,
int&)'
samename.cpp:8: note: candidates are: void bar::foo(int)

class bar {
void foo(int a) { ::foo(a,a); }
};
.
User: "ciccio"

Title: Re: identical function names in and out a class can't compile 11 Jan 2008 06:05:35 AM
Ondra Holub wrote:

On 11 Led, 12:48, ciccio <no_valid_em...@spam.com> wrote:

Hi,

I don't know, but why is this not compiling? As far as I see there is
no ambiguity

<snip>

class bar {
void foo(int a) { ::foo(a,a); }

};

WOOOOW ... respect!!! Thanks a lot
.


User: "Ron Natalie"

Title: Re: identical function names in and out a class can't compile 11 Jan 2008 07:00:42 AM
ciccio wrote:

Hi,

I don't know, but why is this not compiling? As far as I see there is
no ambiguity

regards

[]$ cat samename.cpp
#include <iostream>
void foo(int a, int b) {
std::cout << a+b << std::endl;
}
class bar {
void foo(int a) { foo(a,a); }
};

[]$ g++ -c samename.cpp
samename.cpp: In member function ‘void bar::foo(int)’:
samename.cpp:8: error: no matching function for call to ‘bar::foo(int&,
int&)’
samename.cpp:8: note: candidates are: void bar::foo(int)

First the NAME is looked up. This yields bar::foo
Then overloads for THAT name are considered. THere
is only one overload for bar::foo and that is the one taking a single int.
.


  Page 1 of 1

1

 


Related Articles
compile error with Boost Function object and templated function (Intel C++ compiler)
Value of a const static field in function return at the compile-time
unexpected compile error w/ member function specialization of a template class
Explicit template instantiation from template function doesn't compile?
Can't compile with call to function in global scope
creating a c function at compile or runtime, is this code possible?
why the code can compile -- about function pointer
Compile error when use Boost::lambda::bind function
HELP -- API function won't compile
Compile a function in a program
Log-base-2 function as compile-time constant
private friend member function - should this compile or not?
compile time function selection
Can't compile with call to function in global scope
compile Bjarne Stoustrup's Matrix example under MS Visual C++ 6.0
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER