static-functions Questions

2

Solved

I want to do something like this: interface Serializable<FromType, ToType> { fun serialize(): ToType companion object { abstract fun deserialize(serialized: ToType): FromType } } or ev...

1

Solved

I've been reading a bit about static functions and static member functions. From my understanding if a function is declared static then this function is only visible to it's translation unit ...
Guan asked 20/4, 2020 at 11:58

2

My version (5.4) of gcc warns about unused static functions, even in a header file when -Wall is used. It doesn't complain if the same functions are defined static inline or simply inline. For exa...
Wednesday asked 28/11, 2017 at 23:38

2

Solved

If I define a function in my program.cpp: constexpr bool isThree(const int number) { return number == 3; } is that any different from declaring it static? static constexpr bool isThree(const i...
Campuzano asked 16/5, 2019 at 15:39

1

Solved

I have a basic class that containers two enumerators, one for input and one for output. It has two member functions which are both static. The first function is just a static function that returns ...

4

I'm a bit confused on how constructors work in PHP. I have a class with a constructor which gets called when I instantiate a new object. $foo = new Foo($args); __construct($params) is called in...
Warfield asked 22/11, 2011 at 17:40

15

We make a non-member function a friend of a class when we want it to access that class's private members. This gives it the same access rights as a static member function would have. Both alternati...
Othelia asked 22/2, 2010 at 23:46

4

Is there a way to define static member variables in MATLAB classes? This doesn't work: classdef A properties ( Static ) m = 0; end end It suggests to use keyword "Constant" instead of "Stat...
Devisable asked 23/6, 2011 at 6:37

3

Solved

When should I consider using static functions defined at file scope? I typically use them when the task done in one such function doesn't really belong in member functions of any class and when s...
Holloman asked 8/4, 2015 at 19:52

4

Solved

I have a simple almost value-like class like Person: class Person { public: Person(ThirdPartyClass *object); virtual ~Person(void); virtual std::string GetFullName() const; virtual int GetAge...
Justin asked 30/6, 2011 at 23:33

2

Solved

I have a relatively simple question, and although there are many posts about it on Google, I cannot find a single one that simply answers the question. So the short question is "Is it acceptable t...
Eightfold asked 4/11, 2014 at 23:23

2

Solved

How are unnamed namespaces superior to the static keyword?

2

Solved

My C programming book says that when I want to create a static function, I need to put the static keyword in front of the function definition. It doesn't mention anything explicitly about the proto...
Jacksmelt asked 27/3, 2013 at 21:37

3

Solved

Why is it that every function in most device drivers are static? As static functions are not visible outside of the file scope. Then, how do these driver function get called by user space applicati...

3

Solved

Is there a reason why most function definition in device driver in linux code is defined as static? Is there a reason for this? I was told this is for scoping and to prevent namespace pollution, ...
Asher asked 8/12, 2008 at 9:21

1

Solved

I am getting an error when trying to compile my code in g++ using the current signature: cannot declare member function static void Foo::Bar(std::ostream&, const Foo::Node*) to have static lin...
Keeler asked 15/11, 2011 at 0:23

5

Solved

The declaration below: static int *foo(); declares foo as a static function returning a pointer to an int. What's the purpose of declaring a function as static ?
Lewallen asked 18/10, 2011 at 20:54

7

I have a base class and a derived one and I want to change base functions while keeping them static as they should be passed to other functions as static. How can I do that?

6

Solved

In C++, when you have local variables in a static member function, does it mean those local variables are also implicitly static or are they really local? example: static void myClass::somefunc(i...
Calendre asked 22/12, 2010 at 13:55

2

Solved

I can't get past this issue I am having. Here's a simple example: class x { public: void function(void); private: static void function2(void); }; void x::function(void) { x::function2(void)...
Awl asked 22/3, 2010 at 0:4

5

Solved

So, I'm using the FMOD api and it really is a C api. Not that that's bad or anything. Its just it doesn't interface well with C++ code. For example, using FMOD_Channel_SetCallback( channel, cal...
Otisotitis asked 10/3, 2010 at 20:30
1

© 2022 - 2024 — McMap. All rights reserved.