Questions tagged [ambiguity]

Ambiguity can refer to two related concepts: 'ambiguous calls' and 'ambiguous grammars'.

400 questions
6
votes
2 answers

.ctor is ambiguous because multiple kinds of members with this name exist in class

I am replicating a situation that I am facing. Let's say we have an assembly, with C# class as: public class Program { int n = 0; public void Print() { Console.WriteLine(n); } public Program() { } public…
Brij
  • 11,731
  • 22
  • 78
  • 116
6
votes
5 answers

How to handle a class name conflict when porting old code?

I'm trying to port an old library (that doesn't use namespaces as far as I can tell) to modern compilers. One of my targets can't tell the difference between System::TObject and ::TObject (without a namespace). System::TObject is native to the…
Logomachist
  • 169
  • 1
  • 6
6
votes
3 answers

In RDFa, difference between property="" & rel="", and resource="" & about=""?

I am currently teaching myself RDFa Core 1.1 after successfully learning RDFa Lite rather easily. Straight to the point, I can't understand two things: the difference between property and rel, and the difference between resource and about. Please…
Sketch R
  • 83
  • 5
6
votes
3 answers

Java: Name ambiguity between outer and inner class methods

Suppose I have: public class OuterClass() { public class InnerClass { public void someMethod(int x) { someMethod(x); } } public void someMethod(int x) { System.out.println(x); } } How do I resolve the ambiguity between…
Jake
  • 15,007
  • 22
  • 70
  • 86
6
votes
2 answers

Generics in C# with multiple generic types leads to allowed and disallowed ambiguity

I recently wrote this and was surprised that it compiles: public class MyGeneric { MyGeneric(U u) { ... } MyGeneric(V v) { ... } public void Add(U u, V v) { ... } public void Add(V v, U u) { ... } } If I use this class as follows, I…
Andreas
  • 6,447
  • 2
  • 34
  • 46
6
votes
2 answers

Does C# 4.0 and a combination of optional parameters and overloads give you a warning about ambiguity?

I've started reading Jon Skeet's early access version of his book, which contains sections on C# 4.0, and one thing struck me. Unfortunately I don't have Visual Studio 2010 available so I thought I'd just ask here instead and see if anyone knew the…
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
5
votes
4 answers

How to use 2 C libs that export the same function names

Duplicate of the following question: C function conflict Hi, in my current project I have to use some kind of interface lib. The function names are given by this interface, what this functions do is developers choice. As far as I can tell a project…
DaClown
  • 4,171
  • 6
  • 31
  • 31
5
votes
4 answers

Ambiguous Reference/Value Versions of Functions

Consider the following function prototypes: void Remove(SomeContainer& Vec, const std::size_t Index); SomeContainer Remove(SomeContainer Vec, const std::size_t Index); The second is implemented in terms of the first. That is to say, they are…
Maxpm
  • 24,113
  • 33
  • 111
  • 170
5
votes
4 answers

c++ overload constructor with int and char*

I try to overload constructor with int and char *. Then there is ambiguity in call with 0. Is there any workaround/solution for this? CBigInt (unsigned int); CBigInt (const char *); The problem is on the line with 0: CBigInt a; // some more code a…
ryskajakub
  • 6,351
  • 8
  • 45
  • 75
5
votes
2 answers

Using Markov models to convert all-caps to mixed-case and related problems

I've been thinking about using Markov techniques to restore missing information to natural language text. Restore all-caps text to mixed-case. Restore accents / diacritics to languages which should have them but have been converted to plain…
hippietrail
  • 15,848
  • 18
  • 99
  • 158
5
votes
2 answers

define both operator void* and operator bool

I tried creating a class with one operator bool and one operator void*, but the compiler says they are ambigous. Is there some way I can explain to the compiler what operator to use or can I not have them both? class A { public: operator…
default
  • 11,485
  • 9
  • 66
  • 102
5
votes
2 answers

Disambiguating calls to functions taking std::functions

The code below doesn't compile on gcc 4.5 because the call to foo is ambiguous. What is the correct way to disambiguate it? #include #include using namespace std; void foo(std::function t) { t(1,…
Ted
  • 53
  • 2
5
votes
5 answers

C# ambiguity error when properties are used

I've recently started learning C#. I just learned about properties and decided to make a simple program in order to understand them more. this is the code I wrote: class Dog { private int weight; private string colour; public string…
Adrien
  • 61
  • 1
  • 3
5
votes
1 answer

Is it possible to make this YACC grammar unambiguous? expr: ... | expr expr

I am writing a simple calculator in yacc / bison. The grammar for an expression looks somewhat like this: expr : NUM | expr '+' expr { $$ = $1 + $3; } | expr '-' expr { $$ = $1 - $3; } | expr '*' expr { $$ = $1 * $3; } | expr '/' expr { $$ = $1 /…
wefwefa3
  • 3,872
  • 2
  • 29
  • 51
5
votes
2 answers

How does Swift disambiguate generic constructors?

Consider the following Swift expression println(Generic(1)) Normally, one would read this as a generic call to the constructor Generic with the arguments (1). println( Generic(1) ) However, when re-arranging the tokens…
Clashsoft
  • 11,553
  • 5
  • 40
  • 79