argument-passing

Are there benefits of passing by pointer over passing by reference in C++?

Are there benefits of passing by pointer over passing by reference in C++? Lately, I have seen a number of examples that pass the a pointer instead of passing by reference. Are there benefits to doing this? Example: func(SPRITE *x); with a call of func(&mySprite); vs. func(SPRITE &x); with a call of func(mySprite); ...

Passing multi-dimensional arrays in C

Hey guys, I am currently trying to learn C and I have come to a problem that I've been unable to solve. Consider: #include <stdio.h> #include <stdlib.h> #include <string.h> #define ELEMENTS 5 void make(char **array, int *array_size) { int i; char *t = "Hello, World!"; array = malloc(ELEMENTS * sizeof(char *)); for ...

How can I pass command-line arguments via file association in Vista 64?

How can one pass command line arguments via file association in Vista 64? I recently built a PC running Vista Ultimate 64-bit. I noticed several of the Perl scripts I transferred failed due to command-line arguments not being passed. As a simple test, I wrote the following (foo.pl): #!/usr/bin/perl -w use strict; my $num_args = $#ARG...

Postgres integer arrays as parameters?

I understand that in Postgres pure, you can pass an integer array into a function but that this isn't supported in the .NET data provider Npgsql. I currently have a DbCommand into which I load a call to a stored proc, add in a parameter and execute scalar to get back an Id to populate an object with. This now needs to take n integers ...

How to Pass Decimal Value as Argument Correctly

I have this: double myDecimal = static_cast<double>(atoi(arg_vec[1])); cout << myDecimal << endl; But why when I pass the argument like this: ./MyCode 0.003 It prints 0 instead of 0.003. ...

Prolog ECLiPSe - how to implement yield method?

i'm using ECLiPSe programming logic system. i want to implement the yield method for passing the values from prolog to C/C++. Has anyone implemented it? Are there any other ways for passing the values? ...

Should I be using global variables or passing the variables in java?

Hi all I'm creating a 2d tile based sim game. I have a 2d array of gridSquares, which are accessed and changed from many different classes and methods. Should I pass the 2d array of gridSquares each time, or make it a global? Which is best practice? I was thinking, would it be an option to create a class which just contains a set of va...

How do I pass a hash to a function in Perl?

I am having a lot of trouble. I have a function that takes a variable and an associative array, but I can't seem to get them to pass right. I think this has something to do with function declarations, however I can't figure out how they work in Perl. Does anyone know a good reference for this and how to accomplish what I need? I should a...

C++ - Passing Arrays To Methods

Hello, Here is a function similar to the one I've defined: void Function( BYTE *data ); What I would like to do is something like this: Function( new BYTE { 0x00, 0x00 } ); ...

What is the standardized way to pass complex types in WCF?

I am a newbie in WCF, currently I am developing a TCP WCF service and I am not sure that I understand passing parameters correctly or not so I recommend you to comment and give a standardized way. To get things clear I developed a small service for testing purpose that has single method and depends on an external .Net dll that exposes ...

How do I pass a Generic::List by reference?

In an attempt to wrap some unmanaged code in a managed .dll I'm trying to convert a Generic::List of data points into a std::vector. Here's a snippet of what I'm trying to do: namespace ManagedDLL { public ref class CppClass { void ListToStdVec( const List<double>& input_list, std::vector<double>& output_vector ) ...

Function Decorators

I like being able to measure performance of the python functions I code, so very often I do something similar to this... import time def some_function(arg1, arg2, ..., argN, verbose = True) : t = time.clock() # works best in Windows # t = time.time() # apparently works better in Linux # Function code goes here t = tim...

Passing dynamically allocated integer arrays in C

Hello, I read the example on "Passing multi-dimensional arrays in C" on this site. It is a great example using char arrays, and I learned a lot from it. I would like to do the same thing by creating a function to handle a dynamically allocated one-dimensional integer array, and after that, create another function for handling a multi-...

What are the differences between parameter definitions as (type& name), and (type* name)?

A very basic question, but still, it would be good to hear from C++ gurus out there. There are two rather similar ways to declare by-reference parameters in C++. 1) Using "asterisk": void DoOne(std::wstring* iData); 2) Using "ampersand": void DoTwo(std::wstring& iData); What are implications of each method? Are there any gotcha's...

Error C2228 when constructing boost::function object in constructor argument list

The code below does not compile in Visual C++ 2005. class SomeClass { public: boost::function<void()> func; SomeClass(boost::function<void()> &func): func(func) { } }; void someFunc() { std::cout << "someFunc" << std::endl; } int main() { SomeClass sc(boost::function<void()>(&someFunc)); sc.func(); // error C2228: ...

Splitting /proc/cmdline arguments with spaces

Most scripts that parse /proc/cmdline break it up into words and then filter out arguments with a case statement, example: CMDLINE="quiet union=aufs wlan=FOO" for x in $CMDLINE do »···case $x in »···»···wlan=*) »···»···echo "${x//wlan=}" »···»···;; »···esac done The problem is when the WLAN ESSID has spaces. Users expect to set wlan='...

Passing variables in objective C

Normally i've been passing variable around in init methods, but I can't do that this time because I have a var in one ViewController class displayed using a tab bar and I need access to it from a different ViewController class when a different tab bar is pressed. My understanding was that you can access vars using @property but it's now ...

Querying by type in DB4O

How do you pass a class type into a function in C#? As I am getting into db4o and C# I wrote the following function after reading the tutorials: public static void PrintAllPilots("CLASS HERE", string pathToDb) { IObjectContainer db = Db4oFactory.OpenFile(pathToDb); IObjectSet result = db.QueryByExample(typeof("C...

Using command-line argument for passing files to a program

How can I receive a file as a command-line argument? ...

Pass and access structures using objective-c

I want to know how to pass structures to another function and subsequently access that structure in the called function. I'm developing for the iPhone and the reason I'm using structs is so that I can eventually pass data as structs to a server being built in C. Here's the structure: struct userInfo{ NSString *firstName; NSStri...