argument

Difference between variable-length argument and function overloading

This C++ question seems to be pretty basic and general but still I want someone to answer. 1) What is the difference between a function with variable-length argument and an overloaded function? 2) Will we have problems if we have a function with variable-length argument and another same name function with similar arguments? ...

What is the meaning of leading underscores in a C++ constructor?

OK I am not a very experienced C++ programmer, but I was wondering what is the significance of the underscores in the arguments of the following constructor? class floatCoords { public: floatCoords(float _x, float _y, float _width, float _height) : x(_x), y(_y), width(_width), height(_height) { } float x, y, width, heigh...

default arguments in constructor

Can I use default arguments in a constructor like this maybe Soldier(int entyID, int hlth = 100, int exp = 10, string nme) : entityID(entyID = globalID++), health(hlth), experience(exp), name(nme = SelectRandomName(exp)) { } I want for example exp = 10 by default but be able to override this value if I supply it in the constructor othe...

Expect argument handling

I'd like to create an expect script that connects to the server via telnet and does some authorisation. I have a problem with using script parameters though. Based on man I expected this to work: #!/usr/bin/expect -f spawn telnet $argv1 5038 ... Unfortunately I get back can't read "argv1": no such variable. How can make this work? ...

Nant, SqlCmd -v switch and spaces in nant property fails build with invalid argument

I have a nant script that ... 1. takes the content of disc-file 2. assigns that content to a nant property 3. and then calls sqlcmd with a -v passing in that property containg the content of the disc file 4. inside the sql script the contents of the file should be used by a stored proc. The problem is that when the content of the file ...

"error: too few arguments to function"

I have a C program called opencv2.0 function : cvSaveImage( out_img_name, img); Compiler gcc reports that too few arguments to function cvSaveImage The prototype of cvSaveImage in highgui.h is CVAPI(int) cvSaveImage( const char* filename, const CvArr* image, const int* params CV_DEFAULT(0) ) After I change my call to be ...

To understand Python's optparse

Thank you for quack in pointing out the off-by-one! The following code is my first attempt in writing code with Optparse. How can you fix the following bug in getting the help by Optparse? #!/usr/bin/env python import sys import os from optparse import OptionParser e = sys.argv[1] b = sys.argv[2] no = sys.argv[3] def set_figu(figu)...

Object appended to a list instance appears in a different instance of that list.

Hi, I was writing this little piece of code as an exercise in object-oriented programming. Here I'm trying to define a house as a list of rooms and each room as a list of devices (lamps, for example). First I created all the objects and them appended the two rooms to the house and a different device to each room. Pretty basic. The pro...

Problem using generic map with wildcard

i have a method that returns a map defined as: public Map<String, ?> getData(); the actual implementation of this method is not clear to me, but: when i try to do: obj.getData().put("key","value") I get following compile time error message: The method put(String, capture#9-of ?) in the type Map is not applicable for the ar...

jQuery appendTo gives invalid argument in IE

Hey everyone, I am trying to create an interface to the swfobject found at http://code.google.com/p/swfobject/. I am building the needed alternate content for when the user does not have flash player installed. This is working fine in FF, but not in IE for some reason. I have done this the same way a million times before and it has alwa...

How can I test for null arguments in the constructor of abstract class using rhino mocks?

I have a class like so: public abstract class ClassA<T> { protected ClassA(IInterface interface) { if (interface== null) { throw new ArgumentNullException ("interface"); } } } I want to write a test which verifies that if I pass null in the exception is thrown: [Test] [ExpectedExcep...

Eclipse VM Argument and external JAR file error

I just added "-Djava.library.path=" to the "VM Arguments" under Run Configuration in Eclipse and everything works fine until I tried to add an external JAR file. I get the following error: java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver Exception in thread "main" java.lang.U...

zsh alias -> function ?

Suppose I have: alias gg="git grep" then stuff like: gg "int x" works, but gg int x gets complaints. Is there a way to rewrite gg as a function in zsh so that it takes all the arguments after gg, and stuffs them into a string? Thanks! ...

c++ how to ? function_x ( new object1 )

Hi i want to do the next instead of MyClass object; function_x (object); i want to function_x ( new object ); so what will be the structure of the MyClass to be able to do that .. if i just compiled it , it gives me a compile time error answer function_x (MyClass() ) New Edit thanks for the quick answers.. i did ask the w...

C parsing double from argument strings

I'm trying to parse an argument value in C and convert the number to a double value. I have: char *stringEnd; double num = strtod("123.0", &stringEnd); I used 123.0 just to test the function, but it always returns a value of 0.0. Does anybody know what I'm doing wrong? ...

Get types of arguments in python

I'm learning python. I like to use help() or interinspect.getargspec to get information of functions in shell. But is there anyway I can get the argument/return type of function. ...

When to release/retain an object that is passed to a secondary Thread?

Hello, I am passing an object to a secondary thread using the following code: (void)login:(id)sender { platformMsgs_LoginRequest *loginRequest = [[[platformMsgs_LoginRequest alloc] init] autorelease]; //more code... [NSThread detachNewThreadSelector:@selector(sendLoginRequest:) toTarget:self withObject:loginRequest]; //more code......

In Ruby, how can you invoke a method using its default argument or with a specified argument without repeating code?

Say I have a ruby method: def blah(foo=17) ... end In code I want to invoke blah with a specific argument "blah(a)" or invoke blah using its default argument "blah()" Is there any way to do that without specifying the method name twice? I'm trying to avoid: if a.nil? blah() else blah(a) end Because it makes the code look m...

Drupal 6 views. How to make the views title the node title of the node id argument?

I am using the node id as an argument in a drupal view. However, I want the title of the view to display the title of the node. For example, I have a node with node-id 36 and title "Hello World". The views page url is "example.com/display-node/36" (36 being the node-id passed as an argument). I want the title of the page displayed as "P...

Default value for boost::function argument?

I've got a function that I want to take an optional boost::function argument as a callback for reporting an error condition. Is there some special value I can use a the default value to make it optional? For example, with a regular function pointer I can do: void my_func(int a, int b, t_func_ptr err_callback=NULL) { if (error && (...