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?
...
Can anyone explain the use of ^ operator in java with some examples?Thanks
...
Is there any performance difference between using something like
for(int i = 0; i < 10; i++) { ... }
and
for(int i = 0; i < 10; ++i) { ... }
or is the compiler able to optimize in such a way that they are equally fast in the case where they are functionally equivalent?
Edit:
This was asked because I had a discussion with a co-work...
I'm speaking of this module:
http://docs.python.org/library/operator.html
From the article:
The operator module exports a set of
functions implemented in C
corresponding to the intrinsic
operators of Python. For example,
operator.add(x, y) is equivalent to
the expression x+y. The function names
are those used for special...
I'm in the process of learning Java and my first project is a calculator, however I've run into a snag. I'm trying to get my calculator to let me enter a number then click an operator (+, -, x, /), enter another number then hit an operator again and have the display update and be able to keep this going.
Example, I would like to be abl...
Is there a null coalescing operator in Javascript?
For example, in C#, I can do this:
String someString = null;
var whatIWant = someString ?? "Cookies!";
The best approximation I can figure out for Javascript is using the conditional operator:
var someString = null;
var whatIWant = someString ? someString : 'Cookies!';
Which is so...
Like VB has operators AndAlso and OrElse, that perform short-circuiting logical conjunction, where can equivalent operators be found in JS / AS?
...
VB has operators AndAlso and OrElse, that perform short-circuiting logical conjunction.
Why is this not the default behavior of And and Or expressions since short-circuiting is useful in every case.
Strangely, this is contrary to most languages where && and || perform short-circuiting.
...
I'm working with Ruby on Rails and would like to validate two different models :
if (model1.valid? && model2.valid?)
...
end
However, "&&" operator uses short-circuit evaluation (i.e. it evaluates "model2.valid?" only if "model1.valid?" is true), which prevents model2.valids to be executed if model1 is not valid.
Is there an equivale...
My current question is what does the << operator do in Ruby? But my real question is how would I search Google to find the answer?
...
I have a portion of a bash script that is getting a filename without extension, but I'm trying to understand what is really going on here. What are the "%%"'s for? Can someone elaborate on what bash is doing behind the scenes? How can this technique be used on a general basis?
#!/bin/bash
for src in *.tif
do
txt=${src%%.*}
...
I've been trying to optimize my code to make it a little more concise and readable and was hoping I wasn't causing poorer performance from doing it. I think my changes might have slowed down my application, but it might just be in my head. Is there any performance difference between:
Command.Parameters["@EMAIL"].Value = email ?? Strin...
Here's the situation:
We have some generic graphics code that we use for one of our projects. After doing some clean-up of the code, it seems like something isn't working anymore (The graphics output looks completely wrong).
I ran a diff against the last version of the code that gave the correct output, and it looks like we changed on...
I have the following constructor in my "fraction class"
fraction::fraction(int num, int den=1)
{
numerator=num;
denominator=den;
}
I also have a function called lcm() that returns the least common multiple of values given as parameters. I need to overload the "+" operator in the class fraction. The operator "+" is to add t...
Greetings everyone. Having an issue compiling my script containing the following function. Three errors occur, all on the same line where I set distance += to distances [][]:
error C2108: subscript is not of integral type
error C2108: subscript is not of integral type
error C2297: '+=' : illegal, right operand has type 'double (*)[15]'
...
I see $(var) often in the Actionscript code I am looking through, where var is a variable that is previously defined. What does it mean exactly?
...
can anyone tell me what this operator means exactly? is it the same as != (not equal)??
$foo = 'text';
if($foo <> 'photo') {
echo 'foo';
} else {
echo 'bar';
}
...
What is the difference between == and === in php. I am unsure when to use both.
Updated note: So that it shows up in StackOverflow search, the difference between == and === is the same as the difference between != and !==.
...
I'm not sure the question is clearly worded, but an example will be clearer.
I found out that will not work in Java:
int a = ...;
a = 5.0;
but this will:
int a = ...;
a += 5.0;
I.e., it seems that the = operator is type safe but += isn't.
Is there any deep reason for this or is it just another arbitrary decision language designer...
Can anyone tell me what this cast has for effect (besides setting happyNumber to 1337), if any at all, and if it has no other effect, how come I can write code like this??? Is this a compiler bug, or some "hidden away feature" of C++?
int happyNumber = static_cast<int>(123.456, TRUE, "WTF" , false , "IS" , NULL , "GOING" , 0xff , "ON???...