I'm having trouble deciding whether not this code should compile or if just both compilers I tried have a bug (GCC 4.2 and Sun Studio 12). In general, if you have a static class member you declare in a header file you are required to define it in some source file. However, an exception is made in the standard for static const integrals. ...
I am refreshing myself on OOP with PHP and I saw an example of setting functions and/or variables as static. When and why would I set a variable/function to static? I've done other languages and don't really recall ever using static, I never found a real purpose to it. I know what it does but why not just use a variable instead?
...
How do I create a thread routine of a static member function
class Blah
{
static void WINAPI Start();
};
// ..
// ...
// ....
hThread = (HANDLE)_beginthreadex(NULL, 0, CBlah::Start, NULL, NULL, NULL);
This gives me the following error:
***error C2664: '_beginthreadex' : cannot convert parameter 3 from 'void (void)' to 'unsigne...
I have been writing code without realizing WHY I can access constant values within static
methods.
Why is it possible to access const values without declaring it as static?
E.g.) It's legal to call IMAGE_FILE_EXTENSION within AddImageToDocument(...)
public abstract class ImageDocumentReplacer : DocumentReplacer
{
private const ...
Hi,
I've been noticing static classes getting a lot of bad rep on SO in regards to being used to store global information. (And global variables being scorned upon in general) I'd just like to know what a good alternative is for my example below...
I'm developing a WPF app, and many views of the data retrieved from my db are filtered b...
Hi,
How can I get PHP to evaluate a static variable in double quotes?
I want to do something like this:
log("self::$CLASS $METHOD entering");
I've tried all sorts of {} combos to get the variable value of self::$CLASS, but nothing has worked. I've currently settled with string concatenation but it is a pain to type:
log(self::$CLA...
In the example code
void foo()
{
static Bar b;
...
}
compiled with GCC is it guaranteed that b will be created and initialized in a thread-safe manner ?
In gcc's man page, found the -fno-threadsafe-statics command line option:
Do not emit the extra code to use the
routines specified in the C++ ABI for
thread-safe initiali...
Hi,
How can I serve some static content in liferay? I have a directory structure with htmls, css, etc and I would like to serve it with an address like http://localhost:8080/myStaticContent/index.html and so on.
I don't want to use a front-end http server like apache.
...
Hi,
I'm working on some C++ code and I've run into a question which has been nagging me for a while... Assuming I'm compiling with GCC on a Linux host for an ELF target, where are global static constructors and destructors called?
I've heard there's a function _init in crtbegin.o, and a function _fini in crtend.o. Are these called by c...
The syntax maybe wrong
public static class Storage
{
public static string filePath { get; set; }
}
And
public class Storage
{
private void Storage () {};
public static string filePath { get; set; }
}
I got this from an example on the internet.
what is the use of the second o...
Can an object of ifstream type used for file reading be a static member of a class? I want to read a file and store each line in an array of objects of a class i have created. I want the file reading object to belong to the entire array of objects instead of one single instance of the class.
...
Hi Guys,
I have this:
one string variable which holds the class name ($classname)
one string variable with holds the property name ($propertyname)
I want to get that property from that class, the problem is, the property is static and I don't know how to do that.
If the property weren't static, it would have been:
$classname->$pro...
In a project I have 2 classes:
// mainw.h
#include "IFr.h"
...
class mainw
{
public:
static IFr ifr;
static CSize=100;
...
};
// IFr.h
#include "mainw.h"
...
class IFr
{
public float[mainw::CSize];
};
But I cannot compile this code, getting an error at the static IFr ifr; line. Is this kind of cross-inclusion prohibited?
...
Hello,
I'm currently working on implementing Lua into one of the applications that I'm working on. Currently I'm just using the C api and registering functions using lua_register, but I'd like to be able to pass static and non static function pointers to certain class methods.
I've found certain libraries on the net, but since I need...
Hi all, thanks for checking my problem:)
I'm not able to initialize a static native pointer inside a managed class.
Here's the detail: I created a C++/CLI console project and declared a static unmanaged pointer inside. However I can't initialize the static pointer with any means (but if I put the pointer into an anonymous namespace, th...
Hi what could be the usage of static and extern pointer ?? if they exist
...
Hi All,
I wanted a help in executing a static method asynchronously as well as in it's own process so that even if the client application that kicked-off this execution is closed, the method will continue it's execution.
One option to do this is create a console application and execute this console application as a new process. However...
Using GCC4 in MAC OSX, Linux and Windows.
Thanks.
...
Hi
I have a static class which calls a static Logger class,
e.g
static class DoesStuffStatic
{
public static void DoStuff()
{
try
{
//something
}
catch(Exception e)
{
//do stuff;
Logger.Log(e);
}
}
}
static class Logger
{
public static void Log(Exception e)
{
//do stuff here
...
Why should we use static variables or static calls to static methods in PHP5?
Maybe to improve performance?
...