static-members Questions
4
Solved
Is there any way to use the ECMAScript6 class notation to declare either a static class variable or a default value for an instance variable? Without class what I have in mind would be written as
...
Monomolecular asked 3/2, 2015 at 20:56
4
Solved
I have the following class which I'm using as the base of all the models in my project:
public abstract class BaseModel
{
static String table;
static String idField = "id";
public static bool...
Monochord asked 18/10, 2013 at 18:56
1
Solved
The code below is in the same translation unit and A::v is defined after x, why A::v is not initialized to "ok" ?
#include <string>
#include <iostream>
std::string foo() {
r...
Carrew asked 26/9, 2023 at 9:38
8
Solved
In PHP 5, what is the difference between using const and static?
When is each appropriate? And what role does public, protected and private play - if any?
Odlo asked 6/11, 2009 at 7:10
5
Solved
The question pretty much explains what I want to do. I have several projects in c# which constitute the solution and I want to view the values of static variables at runtime in visual studio. Is th...
Staples asked 14/2, 2013 at 6:52
7
Solved
Consider the following.
struct A {
static const int X = 1;
static void printX() {std::cout << "X " << X << std::endl; };
};
struct B: public A {
static const int X =...
Serb asked 12/11, 2012 at 7:59
4
Solved
error LNK2001: unresolved external symbol "private: static class irrklang::ISoundEngine * GameEngine::Sound::_soundDevice" (?_soundDevice@Sound@GameEngine@@0PAVISoundEngine@irrklang@@A)
I canno...
Barbitone asked 17/4, 2013 at 0:9
4
Solved
This code is giving me incomplete type error.
What is the problem? Isn't allowed for a class to have static member instances of itself?
Is there a way to achieve the same result?
struct Size
{
co...
Cheremkhovo asked 3/3, 2016 at 18:32
2
Solved
Static data member in a class(in C++) will be considered as internal linkage or external linkage ?
I did google but couldn't find out anything concrete for static member variables.
Cajolery asked 18/7, 2014 at 14:12
4
Solved
Here is code, I've been struggling for hours with that, idea is to keep track of how many instances is created, but also make possible to call static method and change/update static member. There i...
Septavalent asked 19/10, 2013 at 20:6
10
Solved
I have this code:
private static $dates = array(
'start' => mktime( 0, 0, 0, 7, 30, 2009), // Start date
'end' => mktime( 0, 0, 0, 8, 2, 2009), // End date
'close' => mktime(23, 59, 59...
Spoliation asked 28/3, 2009 at 22:50
1
Solved
Why and when does the compiler optimize away static member variables? I have the following code
#include <iostream>
#include <typeinfo>
class X {
public:
X(const char* s) { std::cout ...
Predator asked 6/7, 2022 at 13:43
12
Solved
class OuterClass {
class InnerClass {
static int i = 100; // compile error
static void f() { } // compile error
}
}
Although it's not possible to access the static field with OuterClass.Inne...
Subtropics asked 23/12, 2009 at 15:46
3
Solved
The code
#include <iostream>
using namespace std;
template<int n> struct Fibo { static int x; };
template<> int Fibo<0>::x = 1;
template<> int Fibo<1>::x = 1...
Mastoid asked 13/10, 2013 at 12:10
6
Solved
I have a class for local use only (i.e., its cope is only the c++ file it is defined in)
class A {
public:
static const int MY_CONST = 5;
};
void fun( int b ) {
int j = A::MY_CONST; // no probl...
Haemoglobin asked 6/6, 2013 at 8:41
1
Solved
class A {
int x;
static int i;
};
int x = 10;
int A::i = x;
When I compile the code above, it get the error
<source>:8:12: error: invalid use of non-static data member 'A::x'
8 | int A:...
Tierza asked 7/2, 2022 at 10:1
5
Solved
Consider this example code:
template<class D>
char register_(){
return D::get_dummy(); // static function
}
template<class D>
struct Foo{
static char const dummy;
};
template<cl...
Globigerina asked 21/6, 2011 at 6:0
18
Solved
What is the best way to initialize a private, static data member in C++? I tried this in my header file, but it gives me weird linker errors:
class foo
{
private:
static int i;
};
int foo::i = ...
Trigg asked 9/10, 2008 at 3:34
9
Solved
Can anyone explain why following code won't compile? At least on g++ 4.2.4.
And more interesting, why it will compile when I cast MEMBER to int?
#include <vector>
class Foo {
public:
st...
Thermoplastic asked 7/11, 2008 at 17:39
4
Solved
Looks like I can init a POD static const member, but not other types:
struct C {
static const int a = 42; // OK
static const string b = "hi"; // compile error
};
Why?
Sadoff asked 17/7, 2014 at 8:42
1
To clarify, is the following program well-formed?
#include <new>
char foo[32];
struct bar {
static constexpr int foobar = 42;
};
int main()
{
auto p = new (foo) bar();
static_assert(p-&g...
Asdic asked 4/7, 2021 at 19:24
8
Solved
I'm developing an android application which uses web service to get data from server, for that I'm having three different set of URLs to point development system, test server and live server. It's ...
Megalomania asked 22/6, 2012 at 5:38
4
Solved
I am using private static final LOGGER field in my class and I want LOGGER.isInfoEnabled() method to return false.
How can I mock the static final field by using mockito or jMockit
My class is:
...
Harlie asked 8/6, 2015 at 7:14
3
Solved
I have a private static vector in my class that keeps a pointer to all objects created from it. It's necessary as each object needs access to information from all the other objects to perform some ...
Manes asked 4/11, 2020 at 13:12
4
Solved
I have two classes (Model and User) but I have a problem so I have tried to explain it in a simple example :
class person
{
protected static $todo ="nothing";
public function __construct(){}
...
Gyimah asked 30/3, 2016 at 12:9
1 Next >
© 2022 - 2024 — McMap. All rights reserved.