overloading

Overload resolution with extern “C” linkage

扶醉桌前 提交于 2019-12-06 20:42:02
问题 In a mixed C/C++ project, we need to make a call from C to a C++ function. The function to be called is overloaded as three separate functions, but we can ignore that from the C-side, we just pick the one most suitable and stick to that one. There's two ways to do this: (1) write a small C++ wrapper with a extern "C" function that forwards the call to the chosen overloaded function, or (2) the hackish way to just declare the one function we want to call from C as extern "C". The question is,

Java Compile Error: Method reference in combination with overloading

て烟熏妆下的殇ゞ 提交于 2019-12-06 19:36:33
问题 I have the following class with an overloaded method: import java.util.ArrayList; import java.util.concurrent.Callable; public abstract class Test { public void test1 () { doStuff (ArrayList::new); // compilation error } public void test2 () { doStuff ( () -> new ArrayList<> ()); } public abstract void doStuff (Runnable runable); public abstract void doStuff (Callable<ArrayList<String>> callable); } The method test1 results in a compilation error with the error message The method doStuff

How can you overload a function in ActionScript?

眉间皱痕 提交于 2019-12-06 19:33:18
问题 I want a function to be able to take in various types. AS3 doesn't support overloading directly... so I can't do the following: //THIS ISN'T SUPPORTED BY AS3 function someFunction(xx:int, yy:int, someBoolean:Boolean = true){ //blah blah blah } function someFunction(arr:Array, someBoolean:Boolean = true){ someFunction(arr[0], arr[1], someBoolean); } How can I work around it and still have a function that is able to take arguments of various types? 回答1: If you just want to be able to accept any

Why doesn't “use overload” work with “use namespace:autoclean”?

给你一囗甜甜゛ 提交于 2019-12-06 18:47:39
问题 Ok just to sanity check overload doesnt seem to be working for me. I don't know if it's the version of perl I have, or the version of overload.pm, or something wrong with how I've implemented it, but this code doesnt work for me. perl version This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi overload version perl -Moverload -e 'print "$overload::VERSION\n";' 1.07 Token.pm package Token; use namespace::autoclean; use Data::Dumper; use Moose; use Moose::Util::TypeConstraints;

Adding an attribute to a python dictionary from the standard library

流过昼夜 提交于 2019-12-06 18:22:56
问题 I was wondering if you could add an attibute to a python dictionary. class myclass(): def __init__(): self.mydict = {} #initialize a regular dict self.mydict.newattribute = "A description of what this dictionary will hold" >>>AttributeError: 'dict' object has no attribute 'newattribute' setattr(self.mydict,"attribute","A description of what this dictionary will hold" >>>AttributeError: 'dict' object has no attribute 'newattribute' Is there anyway to quickly add my description attribute

How to find an overloaded method in Java?

。_饼干妹妹 提交于 2019-12-06 17:22:48
问题 When writing something like doit(43, 44, "hello"); the compiler knows which overloaded method is to be called. When I want to do the same via reflection, I need to find out myself, that the method is doit(Integer, double, CharSequence...); and obtain it via something like Class[] types = {Integer.class, double.class, CharSequence[].class}; declaringClass.getDeclaredMethod("doit", types); I wonder if there's already something allowing me to write just Method m = getMethod(declaringClass, "doit

Visual C# - Associate event handler with CellDoubleClick event

一世执手 提交于 2019-12-06 15:52:46
I'm working in visual studio and trying to get information from a DataGridView cell when the user double clicks on it. I basically set up the CellDoubleClick event just like any other Click event but that doesn't seem to work. Code: Form1.cs private void dataGridView1_CellDoubleClick(Object sender, DataGridViewCellEventArgs e) { System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder(); messageBoxCS.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex); messageBoxCS.AppendLine(); messageBoxCS.AppendFormat("{0} = {1}", "RowIndex", e.RowIndex); messageBoxCS.AppendLine();

Swift: Method overriding in parameterized class

让人想犯罪 __ 提交于 2019-12-06 13:38:48
I'm very new to Swift but I have some experience with OO-programming. I've started to try and use parameterized classes in Swift and I have come across a strange design feature when overloading methods. If I define the following classes: class ParameterClassA { } class ParameterClassB: ParameterClassA { } class WorkingClassA<T: ParameterClassA> { func someFunction(param: T) -> Void { } } class WorkingClassB: WorkingClassA<ParameterClassB> { override func someFunction(param: ParameterClassA) { } } Then the code compiles fine. However, as you'll notice, I've overloaded the function that normally

C++ Operator Overloading [ ] for lvalue and rvalue

限于喜欢 提交于 2019-12-06 12:07:16
问题 I made a class Array which holds an integer array. From the main function, I'm trying to get an element of the array in Array using [ ] as we do for arrays declared in main. I overloaded the operator [ ] as in the following code; the first function returns an lvalue and the second an rvalue (Constructors and other member functions are not shown.) #include <iostream> using namespace std; class Array { public: int& operator[] (const int index) { return a[index]; } int operator[] (const int

How to overload the PowerShell inbuilt class's methods

偶尔善良 提交于 2019-12-06 11:38:54
问题 Can I overload the PowerShell inbuilt class's methods? If yes then how? Any code sample would be great. Essentially, I am trying to overload the Equals method of a Hashtable Dictionary PowerShell object to do appropriate comparisons. I know that you can overload a cmdlet or a function in PowerShell and whatever is the latest definition that is taken up. But I am trying to overload not a cmdlet or a function, but trying to overload inbuilt method for existing class. I have already checked this