» Home » static » Page 1
Does it make any sense to declare a static variable in a class' function where the object is static
Category : Programming Languages

Lets say my class lets say I have

static classA myObject;
void classA::update(int elapsed)
static int sumElapsed = 0;
sumElapsed+= elapsed;

It seems that my questions is kind of hard to understand. But if we say that myObject is a singleton of classA. Is there a difference between the local static int sumElapsed and a privat

View Replies

Given a list of static libraries and search directories (in GCC/ld format), how to assemble them into a static library
Category : Programming Languages

I have a specific problem, but let me first take a stab at formulating it in a general way:

I am working in Linux (openSUSE 12.2 to be exact). The toolchain is quite standard, using make, OpenMPI mpicc (which uses GCC) and so on.

My problem is essentially that I am given a string of link commands as a macro in a makefile (i.e., "-lsomelib -L/some/path -lanotherlib" and s

View Replies

Can't access asp controls from static method, but when I remove static, ajax call won't work
Category : ASP & ASP.net

I have a method called getPersonInfo and it's header looks like this:

public static Hashtable getPersonInfo(int personID)

The problem I am having is that this method cannot access my asp.net controls. So of course I remove the "static" keyword. But then my ajax calls fail since it's not a static method any more. Any suggestions?

View Replies

Prevent late static binding with static variable access from parent function
Category : Programming Languages

Given the following class hierarchy:

class ParentClass {
private static $_test;
public function returnTest() {
return static::$_test;
class ChildClass extends ParentClass {
// intentionally left blank
$child = new ChildClass();
echo $child->returnTest();

The output generated is

View Replies

How to turn static methods into non-static. Small explanation/examples related to java oop
Category : Java

I cant get how to use/create oop code without word static. I read Sun tutorials, have book and examples. I know there are constructors, then "pointer" this etc. I can create some easy non-static methods with return statement. The real problem is, I just don't understand how it works.I hope some communication gives me kick to move on. If someone asks, this is not homework. I just want to learn h

View Replies

Scope of Connection Static variable inside static method for the entire application?
Category : Programming Languages

I am having the following approach for logging certain things from my java application to Oracle DB.

Package com.util.dblog;
public class DBLog {
static Connection con = null;
static PreparedStatement stmt = null;
static {
DBConnectionHelper connHelper = DBConnectionHelper.createInstance();
con=connHelper.getConnection("ds"); //

View Replies

Is there a way to preserve debug information for a static library that is purely an aggregate of other static libraries?
Category : Programming Languages

I have a project that builds a static library that is purely an aggregate of other static libraries. This is achieved by adding the input libraries to the project as files. However, even if debug information is available for the input libraries, there is none available for the output aggregate library. If debug information is required for the aggregate library when linked into another binary, t

View Replies

Parsing date and running into a 'static reference to the non-static method' Error in java
Category : Java

I have a line in my main like so:

Date gameDate = DateFormat.parse(scanner.nextLine());

Essentially I want to scan in a date with util.Scanner

Which hits the error:

Cannot make a static reference to the non-static method parse(String) from the type DateFormat

Now, I've looked in to this error, but it doesn't seem as clear

View Replies

Access static fields directly instead of calling a static getter method, is it faster?
Category : Programming Languages

I'm writing an Android app and I have a class that generates and maintains some fixed URL's that can occasionally change. I keep them all in one class called UrlUtils:

public class UrlUtils {
private static String sUrlBase = "http://google.com";
* Called occasionally
public static void refreshUrlBases() {
sUrlBase = "http:/

View Replies

“Non-static variable this cannot be referenced from a static context” when I'm trying to instantiate an object - why?
Category : Programming Languages

The program is meant to take in user input info and store it in a arraylist employee object. I'm not exactly sure why these errors are here. Any help?


import java.util.*;
import java.io.*;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
public class P
//Instance Variables
private static Strin

View Replies

2012 / 2017 Copyrights BigHow , All Rights Reserved .