How can i do subtraction of integers in C without using either the unary or binary '-' operator?
Or can we do the same for other data types like float/double?
This is my code:
#include <algorithm>
class A {
void f() {
struct CompareMe {
bool operator() (int i, int j) { return i < j; }
} comp;
int a[] = {1, 2, 3, 4};
int found = std::min_element(a[0], a[3], comp);
}
}
Error message:
no matching function for call to ‘min_element(int&, int&, A::f()::CompareMe&)
What am I doing wrong?
Using LINQ I'm looking to break down the following path string[], however I'd like to break it up to the point of the Binn folder. Is there a WHERE UNTIL operator in LINQ?
c:\ Program Files\ Microsoft SQL
Server\ MSSQL10.SQLEXPRESS\ MSSQL\
Binn\ sqlservr.exe
What I'd like todo
var words = from word in thepath
where UNTIL thepath == "Binn"
select word;
I'm using a classical javascript prototypal inheritance, like this:
function Foo() {}
Naknek.prototype = {
//Do something
};
var Foo = window.Foo = new Foo();
I want to know how I can improve this and why I can't use this model:
var Foo = window.Foo = new function() {
};
Foo.prototype = {
//Do something
};
Why this code doesn't work? In my head this is more logical than the classical prototypal inheritance.
What i want to do is
for (list<cPacket *>::iterator i = cache.begin(); i != cache.end(); i++){
if( strcmp(i->getName(),id) == 0 ){
return true;
}
}
where getName is function of the class cPacket, But it does not work, i tries also
i.operator->()->getName(), and again nothing.
Can anybody help me?
I wrote the following query, I think it's correct but I have a "missing operator" error.
SELECT * FROM results,Types WHERE results.a=Types.b
INTERSECT SELECT * FROM results,Types WHERE results.c=Types.b
Could somebody help me please?
Thanks a lot.
i was learning about c++ pointers... so the "-" operator seemed strange to me... instead of
ptr-hello();
one could write
(*ptr).hello();
because it also seems to work, so i thought the former is just a more convenient way
is that the case or is there any difference?
How can I get ContextMenu that a ToolStripDropDownItem belongs to? This is for the purpose of using the ContextMenu.SourceControl as the logical sender to an event.
I've been reading a couple books/online references about compiler theory, and keep seeing that particular operator coming up every once in a while (as seen here), specifically when the current topic is context free grammars. What does it mean? As well, how does it differ from =>?
Explanations with examples distinguishing => from =*> would be most helpful.
I have a struct like this, with an explicit conversion to float:
struct TwFix32
{
public static explicit operator float(TwFix32 x) { ... }
}
I can convert a TwFix32 to int with a single explicit cast: (int)fix32
But to convert it to decimal, I have to use two casts: (decimal)(float)fix32
There is no implicit conversion from float to either int or decimal. Why does the compiler let me omit the intermediate cast to float when I'm going to int, but not when I'm going to decimal?
To check if a type is a subclass of another type in C#, it's easy:
typeof (SubClass).IsSubclassOf(BaseClass); // returns true
However, this will fail:
typeof (BaseClass).IsSubclassOf(BaseClass); // returns false
Is there any way to check whether a type is either a subclass OR of the base class itself, without using an OR operator or using an extension method?
I have a list of values that i need to check against a constant list to know wheter they are present or not (one by one).
Im using a dictionary buy it doesnt seem logical to have the value two times (key, value)...isnt there any class specialized for this case (and faster if possible)?
I'm scraping data from the web, and I have several processes of my scraper running in parallel.
I want the output of each of these processes to end up in the same file. As long as lines of text remain intact, I the order of the lines does not matter. In UNIX, can I just pipe the output of each process to the same file using the operator?
my string style like this:
expression1/field1+expression2*expression3+expression4/field2*expression5*expression6/field3
a real style mybe like this:
computer/(100)+web*mail+explorer/(200)*bbs*solution/(300)
"+" and "*" represent operator
"computer","web"...represent expression
(100),(200) represent field num . field num may not exist.
I want process the string to this:
/(100)+web*+explorer/(200)bbs/(300)
rules like this:
if expression length is more than 3 and its field is not (200), then add brackets to it.
i am doing:
html = new WebClient().DownloadString("http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=" + biocompany);
and i am getting the error:
Error 1 Operator '&' cannot be applied to operands of type 'string' and 'string'
but i am not even using the & !
please help!
Is there any way to group the edit buttons displayed above the edit dialog in MediaWiki? By grouping, I mean like Word does (and even this editor) - you can add dividing lines to group them so that e.g. Bold and Italic are in one group, numbered list and bullet points in another.
We've added lots of new buttons (in EditPage.php) and they are in a logical order, but at 30 buttons it is a bit overwhelming for some users.
For a little while now javascript has the "map" function to loop over arrays.
It appears possible to use it as a 'foreach' operator for example:
var arr = ['a','b','c']
var doubles = arr.map(function(val){
return val + val
})
Is this better or worse than saying
for(var i in arr){ ...
50/50: saves having to use the index but adds a callback; it doesn't seem very common so I hesitate to use it but still want to.
Hi,
I'm working on a 3D graphical application in Java using the Java 3D API. I noticed that every time I was dealing with transparency, all I got in return were some clipping problems. Some parts of the scene weren't displayed properly. It might seem obvious that this would happen in a certain way but I'm looking for a logical explanation, why is this happening?
Thank you
I need to add several hundred products to an osCommerce (ugh, I know, it wasn't my choice) but osCommerce doesn't have a built in method for this (or at least I couldn't find it), does anyone know where some (even half decent) documentation on HOW osCommerce stores products ('cause it certainly is not in any logical manner) can be found? Or possibly some free addon/software that will do it?
Happily reading xml with
var q2 = from c in xmlDoc.Descendants("Ticket")
select new
{ Responded_Date = (DateTime)c.Element("Responded_Date") }
However when the tag is
<Responded_Date xsi:nil="true" />
I get "String was not recognized as a valid DateTime". I don't wish to use the null coalescing operator but simply to take the null and insert into datatable
These questions are a kind of game, and I did not find the solution for them.
It is possible to write ::: in C++ without using quotes or anything like this and the compiler will accept it (macros are prohibited too).
And the same is true for C# too, but in C#, you have to write ???.
I think C++ will use the :: scope operator and C# will use ? : , but I do not know the answers to them.
Any idea?
I have an 'optional' parameter on a method that is a KeyValuePair. I wanted an overload that passes null to the core method for this parameter, but in the core method, when I want to check if the KeyValuePair is null, I get the following error:
Operator '!=' cannot be applied to operands of type System.Collections.Generic.KeyValuePair<string,object>' and '<null>.
How can I not be allowed to check if an object is null?
Hi
I want to write a video editing software, and the "logical" conclusion is that the language I must to use is C++... But I don't like it (sorry c++ fans)
I would like to write it with something cool, like Lisp or Haskell or Erlang... But I don't know if the open source implementation of those languages (I don't have money to buy licenses) let me made a competitive software (in the performance area)
What do you think? what do you recommend?
i was trying to call a static function of class using scope resolution operator, the way to access static function but still generating error. what are the possibilities.
I have two fields
start_time
end_time - can be null
Now, depending on this I needs to differentiate between three states
Scheduled in future,
Currently running
Completed in past
Since mysql IF operator can not be nested, (Or I cant find an easy way to nest them), I cant find how to get the three state status.