I'm making a method to fetch a list of filenames from a server but I have come to a problem that I cannot answer.
The method returns two things:
an SftpResult which is an enum with a variety of return codes.
the list of filenames.
Of these three signatures:
public static ArrayList GetFileList(string directory, out SftpResult resu...
Lets say I know a guy who is new to C++. He does not pass around pointers (rightly so) but he refuses to pass by reference. He uses pass by value always. Reason being that he feels that "passing objects by reference is a sign of a broken design".
The program is a small graphics program and most of the passing in question is mathematical...
I have a rather weird problem. Because of a certain PECL bug, I pass a var into memcached and it gets changed. The suggested workaround is to pass $data.'' instead of $data and that destroys the reference. But that won't work for me because I don't just pass strings into memcached, I pass all data types.
So I ended up assigning a new v...
I am trying to swap two strings in Java. I never really understood "strings are immutable". I understand in theory but never came across it in practice.
Also, since String is an object in Java and not a primitive type, I don't understand why the following code prints the same result twice, instead of interchanging the words!
public sta...
package {
import flash.display.Sprite;
public class test1 extends Sprite {
private var tmp:Object;
public function test1() {
createObj(tmp);
if(tmp == null) {
trace("nothing changed");
}
}
private function createObj(obj:Object):void {
obj = new Object();
}
}
}
In the above code the output on the console is :
nothin...
Is the passing by reference of a private variable in a class to be directly changed outside that class acceptable practice? Or is this something that the compiler 'should' pick up and prevent?
Example:
//-------------------------------------------
class Others
{
public:
Others() {};
void ChangeIt(string &str) { str = "Changed by Othe...
Possible Duplicates:
const T &arg vs. T arg
How to pass objects to functions in C++?
I used the following code to ascertain that C++ on passing objects as const reference the compiler does not make a copy of the object and send the copy. The output confirmed that passing object as const reference does not involve making a co...
I'm having a pointer problem that I can't seem to figure out. It seems like I've used pointers in this way a 1000 times so I'm not quite sure what is going on here. I have the following code:
int iRetVal;
CycleCountOrder* cycleOrder = NULL;
CycleCountLineItem* cycleLine = NULL;
iRetVal = m_CycleCount.GetCCOrderLine(pOneLocation.szO...
I'm reading manning book about LINQ, and there is an example:
static class QueryReuse
{
static double Square(double n)
{
Console.WriteLine("Computing Square("+n+")...");
return Math.Pow(n, 2);
}
public static void Main()
{
int[] numbers = {1, 2, 3};
var query...
Hi,
I'm using JavaScript Mapping Library - OpenLayer to create a markers overlay.
I want to control the markers dynamically: add new ones and remove existing markers from the layer.
the way to add a new marker to the layer is by the command:
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon));
as you can see, t...
At a lot of places I have seen the following pattern. Consider the code:
Customer cust = (Customer) Session["Customer"];
//Do something to the object cust
Session["Customer"] = cust
and the code :
Customer cust = (Customer) Cache["Customer"];
//do something to object cust
Cache["Customer"] = cust;
Now, in the second case, putti...
I'm a C# programmer writing Java (for Android) and have a few technicalities of Java I'm still not sure about, and worried I'm approaching from a C# angle:
Are parameters in methods passed in the same manner as C#? (Copied for reference types)
Why has the @Override attribute suddenly appeared (I think it's Java 1.5+?)
How is possible t...
So I want to extend for example this RecursiveIterator from the SPL with the function each so i can easily walk over the object/array
class it extends RecursiveArrayIterator {
public function each( $function, $args=array() ){
$args = (sizeof($args)>0) ? array_merge(array($this),(array)$args) : array($this);
iterator_...
I thought when you passed objects to methods in Java, they were supposed to be by value.
Here is my code:
public class MyClass{
int mRows;
int mCols;
Tile mTiles[][]; //Custom class
//Constructor
public MyClass(Tile[][] tiles, int rows, int cols) {
mRows = rows;
mCols = cols;
mTiles = n...
I want to have a a reference that reads as "whatever variable of name 'x' is pointing to" with ints so that it behaves as:
>>> a = 1
>>> b = 2
>>> c = (a, b)
>>> c
(1, 2)
>>> a = 3
>>> c
(3, 2)
I know I could do something similar with lists by doing:
>>> a = [1]
>>> b = [2]
>>> c = (a, b)
>>> c
([1], [2])
>>> a[0] = 3
>>> c
([3], [2]...
Hi guys,
any idea why
foreach ($groups as &$group)
$group = trim(str_replace(',', '', $group));
echo '<pre>';
print_r($groups);
echo '</pre>';
$groupsq = $groups;
foreach ($groupsq as &$group)
$group = '\'' . $group . '\'';
echo '<pre>';
print_r($groups);
echo '</pre>';
Yields
Array
(
[0] => Fake group
[1] => another ...
New to C++ and its giving me a hissy fit.
The actual code is on a different computer and I can't copy it, so I'll do the best I can with pseudo code.
My endgame is to have a vector [of pointers] that can be accessed by several different objects. The way I attempted to go about this is have the original class that contains the vector to...
I've got a recursive function defined as follows
private function _buildPathwayRecurse(&$category, &$reversePathway = array()) {
$category->uri = FlexicontentHelperRoute::getCategoryRoute($category->id);
$reversePathway[] = $category;
if ($category->parent_id != 0) {
$category = $this->_getCatForPathway($category->parent_id);...
Specifically, I want to use rcols with the PERLCOLS option.
Here's what I want to do:
my @array;
getColumn(\@array, $file, 4); # get the fourth column from file
I can do it if I use \@array, but for backward compatibility I'd prefer not to do this. Here's how I'd do it using an array-ref-ref:
sub getColumn {
my ($arefref, $f...
I have the following problem with objects in actionscript3:
var o:Object = new Object();
destroyObject(o);
trace(o); // [object Object]
function destroyObject(obj:Object):void{
obj = null;
trace(obj); // null
}
Since objects are passed by reference in AS3 I assume that the previous code would change o to null, but it doesn't. ...