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 wrong Question i should have asked how
temporary variables created in C++ and the answer
Sorry if this is quite noobish to you, but I'm just starting out to learn Python after learning C++ & Java, and I am wondering how in the world I could just declare variables like id = 0 and name = 'John' without any int's or string's in front! I figured out that perhaps it's because there are no ''s in a number, but how would Python figure that out in something like def increase(first, second) instead of something like int increase(int first, int second) in C++?!
Not sure if many people are familiar with Scaffolding Extensions for Ruby, but I've looked through their docs, forums, and even the source code of the Heroku test site, and not found an answer.
I made a basic Sinatra app and followed right from the RDoc's instructions:
require 'scaffolding_extensions'
require 'sinatra/base'
class Thingy < Sinatra::Base
scaffold_all_models
end
gives
undefined method 'scaffold_all_models' for Thingy:Class (NoMethodError)
and I know Scaffolding Extensions is loadable because I can successfully set some config variables in its classes.
I have multiple language packs in my NSIS installer, using the MUI2 interface. Now I try to select the language pack, which is installed by the "Typical" installation type according to the user's chosen setup language. My problem is, that I can't figure out, how to get the user's language selection.
I already tried to access the variables $LANGUAGE and $mui.LangDLL.RegistryLanguage, as well as trying to compare a defined language string to a specific translation string, but without success.
I just found out, that it seems a common pattern to user UpperFirstLetterPascalCase() for private methods. I for myself, find this completely inconsistent with naming rules of private instance fields and variables and I find it difficult to read/debug, too.
I would want to ask, why using a first upper letter for methods could be a better choice than a first lower (doThis())? Just out of curiosity...
The following post indicates how to make a simple get http request with Erlang's inets.
exploring erlang's http client
Sometimes, URLs have GET parameters:
http://example.net/item?parameter1=12¶meter2=1431¶meter3=8765
Besides including the parameters in the URL itself, is there a way to create variables and then send them with the request?
Example appreciated.
Hi All
Is it possible, in any way, to pass comparison operators as variables to a function? I am looking at producing some convenience functions, for example (and I know this won't work):
function isAnd($var, $value, $operator = '==')
{
if(isset($var) && $var $operator $value)
return true;
}
if(isAnd(1, 1, '===')) echo 'worked';
Thanks in advance.
Hi there,
I have a program that needs to use sleep. Like really needs to. In lieu of spending ages explaining why, suffice to say that it needs it.
Now I'm told to split off my code into a separate thread if it requires sleep so I don't lose interface responsiveness, so I've started learning how to use NSThread. I've created a brand new program that is conceptual so to solve the issue for this example will help me in my real program.
Short story is I have a class, it has instance variables and I need a loop with a sleep to be depended on the value of that instance variable.
Here's what I've put together anyway, your help is very much appreciated :)
Cheers
Tim
/// Start Test1ViewController.h ///
#import <UIKit/UIKit.h>
@interface Test1ViewController : UIViewController {
UILabel* label;
}
@property (assign) IBOutlet UILabel *label;
@end
/// End Test1ViewController.h ///
/// Start Test1ViewController.m ///
#import "Test1ViewController.h"
#import "MyClass.h"
@implementation Test1ViewController
@synthesize label;
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
label.text = @"1";
[NSThread detachNewThreadSelector:@selector(backgroundProcess) toTarget:self withObject:nil];
}
- (void)backgroundProcess {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// Create an instance of a class that will eventually store a whole load of variables
MyClass *aMyClassInstance = [MyClass new]; [aMyClassInstance createMyClassInstance:(@"Timbo")];
while (aMyClassInstance.myVariable--) {
NSLog(@"blah = %i",aMyClassInstance.myVariable);
label.text = [NSString stringWithFormat:@"blah = %d", aMyClassInstance.myVariable];
//how do I pass the new value out to the updateLabel method, or reference aMyClassInstance.myVariable?
[self performSelectorOnMainThread:@selector(updateLabel) withObject:nil waitUntilDone:NO];
//the sleeping of the thread is absolutely mandatory and must be worked around. The whole point of using NSThread is so I can have sleeps
[NSThread sleepForTimeInterval:1];
}
[pool release];
}
- (void)updateLabel {label.text = [NSString stringWithFormat:@"blah = %d", aMyClassInstance.myVariable]; // be nice if i could }
- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];}
- (void)viewDidUnload {}
- (void)dealloc {[super dealloc];}
@end
/// End Test1ViewController.m ///
/// Start MyClass.h ///
#import <Foundation/Foundation.h>
@interface MyClass : NSObject {
NSString* name;
int myVariable;
}
@property int myVariable;
@property (assign) NSString *name;
- (void) createMyClassInstance: (NSString*)withName;
- (int) changeVariable: (int)toAmount;
@end
/// End MyClass.h ///
/// Start MyClass.h ///
#import "MyClass.h"
@implementation MyClass
@synthesize name, myVariable;
- (void) createMyClassInstance: (NSString*)withName{
name = withName;
myVariable = 10;
}
- (int) changeVariable: (int)toAmount{
myVariable = toAmount;
return toAmount;
}
@end
/// End MyClass.h ///
In php we use includes. So variables defined in one file and then their scope spans included files too.
Zend studio has no idea how to get the type of the variable I am using inside an included file, this is very annoying when the variable type is a big class.
Is there a way to hint the ide about variable types? in included files?
With VIM or Emacs I can put comments in the file that will be VIM's settings for that file:
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* c-indentation-style: linux
* indent-tabs-mode: nil
* default-tab-width: 8
* fill-column: 125
* End:
*
* vim: et:sw=4:ts=8:si:cindent:cino=\:0,g0,(0:
*/
Can the same be done with Nedit?
I understand it is a very basic concept in the oops. But still I cannot get my head around. I understood why member variables are private, so class user cannot abuse it by setting up invalid values.
But how can this apply to the methods ?
For a simple simulation in C, I need to generate exponential random variables. I remember reading somewhere (but I can't find it now, and I don't remember why) that using the rand() function to generate random integers in a fixed range would generate non-uniformly distributed integers. Because of this, I'm wondering if this code might have a similar problem:
//generate u ~ U[0,1]
u = ( (double)rand() / ((double)(RAND_MAX));
//inverse of exponential CDF to get exponential random variable
expon = -log(1-u) * mean;
Thank you!
I know that app config is used to provide environmental type of values for process variables. And it is very much key/value oriented.
But I have a process (windows service) that uses a skeleton xml template file to produce a fuller version of that file after processesing.
What about the idea of including that 'skeleton xml' in the app config file?
I am trying to aviod having a standalone xml skeleton file, since it is 'configuration' related, in a way.
Hi
I've got a Flex 3 project. I'm having a problem with XML in Internet Explorer only. Pls see the problem lines below:
_clickURL = [email protected]();
_mediaSource = [email protected]();
These variables are coming up "" in IE. But, they grab the data in Safari and Firefox.
Any suggestions as to what the problem might be? Possible solution?
Thank you.
-Laxmidi
Hi Everyone,
Are there any ways to retrieve the database connection string where my ruby is connected? what i would like to get is the:
1) Database name where the ruby is connected
2) The username of the SQL Server
3) Password of the SQL Server
4) Server name
I want to store it in session variables.
(I'am using MS SQL Server.)
Please help! thanks!
After adding the new facebook like button to my page, it no longer validates using XHTML strict. The two errors I come across are:
All of the "meta property" tags say that "there is no attribute "property""
All of the variables used in the like button line are listed that there are no attributes for it. The line is as follows:
<fb:like href="http://www.pampamanta.org" layout="button_count" show_faces="false" width="120" action="like" font="arial" colorscheme="light"></fb:like>
I have a Fitnesse test that I want to run twice. Once in firefox and once in ie. The test is below. The problem I am having is that only the second test is being executed by fitnesse
!define COMMAND_PATTERN {%m %p}
!define TEST_RUNNER {dotnet2\FitServer.exe}
!****>Global Variables
!define testUrl {http://localhost:1516/Web.App/Login.aspx}
*****!
!define browserToUse (IE)
!include -c -seamless .FrontPage.LoginTests
!define browserToUse (FireFox)
!include -c -seamless .FrontPage.LoginTests
I installed ghostscript and updated the appropriate path variables ... however, I'm getting an error when I try to execute this command:
C:\PROGRA~1\gs\gs8.64\lib>pdf2ps mydocument.pdf mydocument.ps
Access is denied.
Unable to open command line file _.at
Is this the right command? did I miss some configuration or path setting? Otherwise, is there a sane method of doing this conversion?
Thanks!
I have an app that is a TableView that drills down to a Detail View (UIView). On the detail view, I have three buttons that each add a different view to the stack. But I also want to pass some of the NSString variables from the detail view to the newly added views. How do I do that?
Hi All,
I was writing a C program where I use 6 variables a,b,c,d,e,f
a,b,c are constant values which I should pass as an argument(command line)
d,e,f are going to be size of arrays(which are a part of a structure)
typedef struct
{
blah blah
} ex;
ex ex0[d];
I am very confused about how to pass all these as argument. Right now I have hard coded these values,which apparently I should not be doing.
Scala has symbols - names that start with a single quote ' and which are a kind of string constants.
I know symbols from Ruby (where they start with a colon). In Ruby they are used for some meta-programming tasks, like generating getters and setters for member variables (for example attr_reader :name to generate a getter for name).
I haven't seen a lot of use of symbols in Scala code yet. What are practical uses for symbols in Scala?
For most programmers using procedural or object-oriented languages there is a language-feature lowest common denominator: variables, procedures, standard control structures, and classes.
However, almost all languages add features on top of this. Recent C# versions have LINQ and delegates. C++ has template metaprogramming. Java has annotations. What features such as these do you use every day?
is it possible in some way to compare multiple variables to one constant in a if statement? It would be very helpful if instead of
if ( col.Name != "Organization" && col.Name != "Contacts" && col.Name != "Orders" ) { }
I could just say
if ( col.Name != "Organization" || "Contacts" || "Orders" ) { }
And I know I could use a list but in some instances I dont want to... Thanks!