I have a class similar to boost::any, in that it is a templated container class. I'd like to have a method to write the contained value to a string. However, if the contained type doesn't provide a stream insertion operator, I'd like my method to return some default tring rather than failing to compile. Below is as close as I've come, an...
I'm trying to create a function which is overloaded based on the specialization of its parameter, such as this:
class DrawableObject...;
class Mobile : public DrawableObject...;
class Game
{
AddObject(DrawableObject * object)
{
// do something with object
}
AddObject(Mobile * object)
{
AddObject(dyna...
Question edited to better reflect my needs.
Take the following example:
class Base
{
public $Text = null;
public function __construct()
{
$this->Text = new Base_Text();
}
}
class Base_Text extends Base
{
public $Is = null;
public function __construct()
{
$this->Is = new Base_Text_Is();
...
Is it possible to have an overloaded function in classic asp JScript
...
Is it possible to create a constructor (or function signature, for that matter) that only accepts a string literal, but not an e.g. char const *?
Is it possible to have two overloads that can distinguish between string literals and char const *?
C++ 0x would kind-of allow this with a custom suffix - but I'm looking for an "earlier" sol...
I'm wrestling with a weird, at least for me, method overloading resolution of .net. I've written a small sample to reproduce the issue:
class Program
{
static void Main(string[] args)
{
var test = new OverloadTest();
test.Execute(0);
test.Execute(1);
Console.ReadLine();
}
}
public class Over...
What is the difference between override and overload?
...
I have code that computes the absolute value of a custom value type:
public Angle Abs(Angle agl)
{
return (360 - Angle.Degrees);
}
This isn't my actual application but it will serve my point. Then I have a method like so:
public dynamic DoStuff(Foo f)
{
// f contains a list of value types: int, double, decimal, angle
retu...
Yeah, the title can scare babies, but it's actually quite straightforward.
I am trying to store a function pointer to a specialized template function, namely boost::make_shared (boost 1.41), as illustrated:
boost::shared_ptr<int> (*pt2Function)() = boost::make_shared<int>;
However, it won't compile (GCC 4.4.1) due to the fact that bo...
http://stackoverflow.com/questions/442026/function-overloading-by-return-type
has a very detailed answer on the rational on function overloading by return type, and from what I can see Delphi does not allow this, but are there any workarounds to overload a function based on different return type in Delphi?
...
Scenario
I have the following two overloads that I need in order to instantiate two different derived objects from the base class.
Issue
The compiler has a problem with this code since the methods are ambiguous - both taking two strings as arguments.
Question
How can I get round this problem so that the following below code compiles...
Hello, i have a problem with function overloading. I will show you with some simple example:
class A {};
class B : public A{};
void somefunction(A&, A&);
void somefunction(B&, B&);
void someotherfunction() {
...
A& a1 = ...
A& a2 = ...
...
}
Both a1 and a2 are instances of B but
somefunction(a1,a2);
calls
void somefunction(A&, ...
Hello *,
experimenting with Visitor pattern and generic method I found a kind of discrepancy in C#.NET. AFAIK C# compiler prefers an explicit overload to a generic method, therefore the following code:
public abstract class A
{
public abstract void Accept(Visitor v);
}
public class B : A
{
public override void Accept(Visitor v...
I know it can't be done, well I hope it can't or my Google skills have failed me.
But my annoyance is beyond that now, I have abandoned all hope of ever being able to overload my constructors in PHP, so what I'd really like to know is why. Is there even a reason for it? Does it create inherently bad code? Is it widely accepted language ...
Overloading constructors and methods seems messy, i.e. simply differentiating them by the order and number of parameters. Isn't there a way, perhaps with generics, to do this cleanly so that, even if you just have one parameter (e.g. string idCode / string status) you could still differentiate them?
using System;
namespace ConsoleAppli...
Altough I already know it's not possible, as my understanding how programming works, I would like to have a confirmation of this.
I have an enum
typedef enum {
enum_first=1,
enum_second=2
} myenum
I wanted to do overloading of method, this syntax is obviously wrong, but it gives the idea:
-(id)myenumTest:(myenum.enum_first)value {.....
I want to define a class MyStream so that:
MyStream myStream;
myStream << 1 << 2 << 3 << std::endl << 5 << 6 << std::endl << 7 << 8 << std::endl;
gives output
[blah]123
[blah]56
[blah]78
Basically, I want a "[blah]" inserted at the front, then inserted after every non terminating std::endl ?
The difficulty here is NOT the logic ma...
I've done plenty of Method Overloading, but now I have an instance where I would like to Overload a Property. The IDE in Visual Studio seems to allow it, since I can actually set up the two overloads, but I get an error saying it is not valid because they only differ in type. I think I'm missing something in my syntax?
I want to be ab...
Hi.
I have a feeling this question is a can of worms but I am going to ask anyway... :)
I have a method:
private MembershipUser GetUserFromReader(SqlDataReader reader)
And I want overload this method with a different return type:
private User GetUserFromReader(SqlDataReader reader)
But the compiler complains that the two method...
I'm trying to create a property that will allow the setting of a last name based on a variety of inputs. The code that calls this is parsing a name field. In some instances it will have a single last name, in others, a array of last names that need to be concatenated. I want to keep my concatenation code in a single place to make mainten...