Method invocation will consist of the following steps:
1. Member lookup (14.3) - evaluate method group set (Base.f() and
Derived.f()) .Standart say:
"The compile-time processing of a method invocation of the form M(A), where
M is a method group and A is
an optional argument-list, consists of the following steps:
The set of candidate methods for the method invocation is constructed.
Starting with the set of methods
associated with M, which were found by a previous member lookup (14.3),
...."
2. Remove non-applicable methods and methods of base classes. In this
example both Base.f() and Derived.f() are applicable. Standart say:
"... the set is reduced to those
methods that are applicable with respect to the argument list A. The set
reduction consists of applying
the following rules to each method T.N in the set, where T is the type in
which the method N is declared:
If N is not applicable with respect to A (14.4.2.1), then N is removed from
the set.
If N is applicable with respect to A (14.4.2.1), then all methods declared
in a base type of T are removed
from the set."
But what mean words "then all methods declared in a base type of T are
removed from the set"? If all methods must be removed than test() method in
example must invoke Derived.f(), but MSVC# invoke Base.f(). Why? Any
suggestions.
class Source
{
static public implicit operator Target ( Source source )
{ return new Target(); }
}
class Target
{}
class Base
{
public void f ( Source source )
{}
}
class Derived : Base
{
public void f ( Target target ) // this function is applicable
(user-defined implicit conversion used)
{}
public void test()
{
Source source = new Source();
f ( source ); // invoke Base.f() - why?
}
}
Alex. 4 1479
Alex Sedow wrote: Method invocation will consist of the following steps:
1. Member lookup (14.3) - evaluate method group set (Base.f() and Derived.f()) .Standart say: "The compile-time processing of a method invocation of the form M(A), where M is a method group and A is an optional argument-list, consists of the following steps: The set of candidate methods for the method invocation is constructed. Starting with the set of methods associated with M, which were found by a previous member lookup (14.3), ..."
2. Remove non-applicable methods and methods of base classes. In this example both Base.f() and Derived.f() are applicable. Standart say: "... the set is reduced to those methods that are applicable with respect to the argument list A. The set reduction consists of applying the following rules to each method T.N in the set, where T is the type in which the method N is declared: If N is not applicable with respect to A (14.4.2.1), then N is removed from the set. If N is applicable with respect to A (14.4.2.1), then all methods declared in a base type of T are removed from the set."
But what mean words "then all methods declared in a base type of T are removed from the set"? If all methods must be removed than test() method in example must invoke Derived.f(), but MSVC# invoke Base.f(). Why? Any suggestions.
class Source { static public implicit operator Target ( Source source ) { return new Target(); } }
class Target {}
class Base { public void f ( Source source ) {} }
class Derived : Base { public void f ( Target target ) // this function is applicable (user-defined implicit conversion used) {}
public void test() { Source source = new Source(); f ( source ); // invoke Base.f() - why? } }
In my test, Derived.test() invokes Derived.f().
--
mikeb
Alex Sedow wrote: Method invocation will consist of the following steps:
1. Member lookup (14.3) - evaluate method group set (Base.f() and Derived.f()) .Standart say: "The compile-time processing of a method invocation of the form M(A), where M is a method group and A is an optional argument-list, consists of the following steps: The set of candidate methods for the method invocation is constructed. Starting with the set of methods associated with M, which were found by a previous member lookup (14.3), ..."
2. Remove non-applicable methods and methods of base classes. In this example both Base.f() and Derived.f() are applicable. Standart say: "... the set is reduced to those methods that are applicable with respect to the argument list A. The set reduction consists of applying the following rules to each method T.N in the set, where T is the type in which the method N is declared: If N is not applicable with respect to A (14.4.2.1), then N is removed from the set. If N is applicable with respect to A (14.4.2.1), then all methods declared in a base type of T are removed from the set."
But what mean words "then all methods declared in a base type of T are removed from the set"? If all methods must be removed than test() method in example must invoke Derived.f(), but MSVC# invoke Base.f(). Why? Any suggestions.
class Source { static public implicit operator Target ( Source source ) { return new Target(); } }
class Target {}
class Base { public void f ( Source source ) {} }
class Derived : Base { public void f ( Target target ) // this function is applicable (user-defined implicit conversion used) {}
That's not true. The convertion is applied when you
call the method. So you still have 2 distinct methods:
f(Source)
f(Target) public void test() { Source source = new Source(); f ( source ); // invoke Base.f() - why?
because f(Source) is still visible and it is the best match.
Bye
Rob
"mikeb" <ma************@nospam.mailnull.com> wrote in message
news:#a**************@TK2MSFTNGP11.phx.gbl... In my test, Derived.test() invokes Derived.f().
-- mikeb
You right. Sorry. I not there have seen.
Alex.
"Robert Jordan" <ro*****@gmx.net> wrote in message
news:ch*************@news.t-online.com... That's not true. The convertion is applied when you call the method. So you still have 2 distinct methods:
f(Source) f(Target)
public void test() { Source source = new Source(); f ( source ); // invoke Base.f() - why?
because f(Source) is still visible and it is the best match.
Bye Rob
I not there have seen.
f ( source ) invoke Derived.f().
Alex. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ReignMan |
last post by:
I'm running JDK 1.4.0_01, Xalan2.5.1 and Tomcat 4.1.27. XSL
transformations work, yet when running in debug mode (Eclipse IDE), I
get the following:
990S2html.xsl:3:80: Element type...
|
by: cppaddict |
last post by:
Hi,
I know that it is illegal in C++ to have a static pure virtual method,
but it seems something like this would be useful when the following 2
conditions hold:
1. You know that every one...
|
by: Duck Dodgers |
last post by:
Here is my situation
class base {
};
class child1 {
int data;
};
class child2 {
|
by: Derek |
last post by:
I am writing a web application for job seekers, and am adding a
section that allows administrators to upload jobs to the system via
xml. I have used an xml schema to validate the xml they upload....
|
by: Ken Brady |
last post by:
I'm on a team building some class libraries to be used by many other
projects.
Some members of our team insist that "All public methods should be virtual"
just in case "anything needs to be...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
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...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
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...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
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...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |