Good points! just a side note to people who might not know! You need to declare the variable as "extern" in a header file to be able to see it in other sources (or translation units).
Members of classes, both functions and variables that are static have another feature in that they are accessible _without instatiating an object_ of that class. Example: class Test { public: int a; static int b; static void testFunc() {} }; int main() { Test::b = 2; // Ok Test::testFunc(); // Ok Test::a = 1; // ERROR Test *t = new Test(); t->a = 4; // Ok t->b = 6; // Ok t->testFunc(); // Ok std::cout
A global is accessible to every function in the application. "Local to the module" means accessible to function [below the declaration] in the same file.
There is no @ operator in standard C. Some non-standard C extensions support that feature but exactly how it's used might vary from compiler to compiler so you'll have to consult the documentation of whatever compiler you're using.
Excellent content, subscribed 🤝
Good points! just a side note to people who might not know! You need to declare the variable as "extern" in a header file to be able to see it in other sources (or translation units).
Thanks for creating these videos, you are great at explaining stuff.
Thanks! This explanation was very helpful!
I may have missed it in this video but you can also have static functions in C.
cool thanks for the good explanation!
Can you please do a video explaining the difference between binary semaphore and mutex?
binary has only two states, mutex is more like a stack that can go to the negative.
Thanks for the darker text, much easier to read...
Members of classes, both functions and variables that are static have another feature in that they are accessible _without instatiating an object_ of that class. Example:
class Test
{
public:
int a;
static int b;
static void testFunc() {}
};
int main()
{
Test::b = 2; // Ok
Test::testFunc(); // Ok
Test::a = 1; // ERROR
Test *t = new Test();
t->a = 4; // Ok
t->b = 6; // Ok
t->testFunc(); // Ok
std::cout
does static just mean a special global variable but not all functions can access it?
In effect, yes.
what a G
great video
So, if a class (object instance) has a static variable, do I need to use mutexes when setting/reading its value?
Is "static" has to do something with "entrant" and "reentrant" function???
No
what is the difference between global and "local to the module".
A global is accessible to every function in the application. "Local to the module" means accessible to function [below the declaration] in the same file.
Good review. Thanks.
Maybe do a vid on the @ operator in C (i.e absolute address)
There is no @ operator in standard C. Some non-standard C extensions support that feature but exactly how it's used might vary from compiler to compiler so you'll have to consult the documentation of whatever compiler you're using.
very helpful
Would you be nice to let me know which tool and other apps you are using to record this video ?
Why are there classes? This is C++, not C.
Is this about java or c programming :(
The title says it: C.