overloading

How to export Overload functions from DLL?

偶尔善良 提交于 2019-12-10 16:16:15
问题 Delphi Xe. In module Windows.pas I see one of methods: function InterlockedExchangeAdd(Addend: PLongint; Value: Longint): Longint stdcall; overload; {$EXTERNALSYM InterlockedExchangeAdd} function InterlockedExchangeAdd(var Addend: Longint; Value: Longint): Longint stdcall; overload; {$EXTERNALSYM InterlockedExchangeAdd} ... function InterlockedExchangeAdd(Addend: PLongint; Value: Longint): Longint; external kernel32 name 'InterlockedExchangeAdd'; function InterlockedExchangeAdd(var Addend:

Why is method overloading not working in this C# program?

会有一股神秘感。 提交于 2019-12-10 15:35:39
问题 namespace test { class Program { static void Main(string[] args) { Derived obj = new Derived(); int i = 10; obj.Foo(i); Console.ReadLine(); } } class Base { public virtual void Foo(int i) { Console.WriteLine("Base:Foo()"); } } class Derived:Base { public override void Foo(int i) { Console.WriteLine("Foo(int)"); } public void Foo(object i) { Console.WriteLine("Foo(object)"); } } } output of the program according to me should be Foo(int) but output is coming as Foo(object) please help me in

Call nonconst member version from const [duplicate]

穿精又带淫゛_ 提交于 2019-12-10 15:03:08
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: How do I remove code duplication between similar const and non-const member functions? i have two members A &B::GetA (int i) { return *(m_C[m_AtoC[i]]); } const A &B::GetA (int i) const { return *(m_C[m_AtoC[i]]); } for now i just duplicate code, but may be there exists nice way to do it. I certanly dont want to deal with type cast from const to non-const. EDIT: So i want to call one member frm another to avoid

ambigious functions in c++

孤人 提交于 2019-12-10 14:49:09
问题 I would like to know why these declarations won't work(are not compatible) void f(int); //p1 void f(const int);//p2 void f(int &);//p3 void f(const int &);//p4 If I understood well, the compiler won't find a difference between (int &) and (const int &) and if I write f(12) it won't be able to choose between the two first declarations.. Am I right? 回答1: p3 and p4 are perfectly unambiguous and distinguishable, p1 and p2 are not. (And of course p1/p2 are distinguishable from p3 and p4.) The

Overloading a method with parameter Func<T>

こ雲淡風輕ζ 提交于 2019-12-10 14:43:09
问题 I would like to create a few overloaded methods which accept a Func parameter. The overloaded methods should call the method with the most generic types defined in the parameter. Below is a quick example of my methods, and how I would like to call them: public static TResult PerformCaching<TResult, T1>(Func<T1, TResult> func, T1 first, string cacheKey) { return PerformCaching((t, _, _) => func, first, null, null, cacheKey); } public static TResult PerformCaching<TResult, T1, T2>(Func<T1, T2,

operator>>(,) overload behaving in a surprising way

巧了我就是萌 提交于 2019-12-10 14:37:21
问题 Well, maybe it is not so surprising. Stackoverflow has a lot of questions and contributions to that point. Only they are not EXACTLY to the point. Here an extract from the C++ standard (in fact a c++14 draft, but I assume the passage is the same in current C++11 standard): An operator function shall either be a non-static member function or be a non-member function that has at least one parameter whose type is a class, a reference to a class, an enumeration, or a reference to an enumeration.

Template function overload for base class [duplicate]

时光怂恿深爱的人放手 提交于 2019-12-10 13:25:32
问题 This question already has answers here : Priority when choosing overloaded template functions in C++ (6 answers) Closed 20 days ago . How do I force compiler to pick up a template function overload for a base class? Here is an example that illustrates the question #include <iostream> class A {}; class B : public A {}; template <class T> void f (const T& t) { std::cout << "Generic f" << std::endl; } void f (const A& a) { std::cout << "Overload for A" << std::endl; } template <class T> void

Elixir: function overloading with different arity

為{幸葍}努か 提交于 2019-12-10 13:08:45
问题 is there any way to define overload functions with different arity, e.g in C# I can just do: foo(bar) or foo(bar, baz) In Elixir, the only way to do that would be to put them in separate modules, which will get messy pretty quickly. Is there any way around it? Edit: I had made a wrong assumption. The examples of overloaded functions I saw happened to have the same arity, so I (wrongly) assumed that this was a requirement. Functions are uniquely identified by their name and arity, so you can

Can Visual Studio's C# intellisense be given a hint to display a certain method overload first?

笑着哭i 提交于 2019-12-10 12:38:58
问题 I have two methods that are overloads of each other public class Car { public int GetPrice(string vinNumber) { string make = Database.GetMake(vinNumber); // expensive operation string model = Database.GetModel(vinNumber); // expensive operation int year = Database.GetYear(vinNumber); // expensive operation return this.GetPrice(make, model, year); } public int GetPrice(string make, string model, int year) { // Calculate value and return } } In my example, the GetPrice(make, model, year)

find which function(file) causes server overload

谁都会走 提交于 2019-12-10 12:06:31
问题 I have read this topic, but my topic is not duplicate. It will be excellent, if I had an specific helper function/method, which will track all further functions, which are being executed in PHP, to determine the each function's execution time, like this: executed URL: /mypage.php function execution times: initialize(): 1.2 seconds - cookie_checker(): 0.1 ms -- set_cookie(): 0.01 ms -- blabla(): 0.5 ms - start_authorization(): 0.27 ms page_output(): 2.4 seconds - header_output(): 0.3 ms --