A question about functions

V

vineoff

What does static mean in front of function. Like:

static void f();

I know what it means when function f is in a class, but when it's not
in class, what does that mean then?
 
F

Ferdi Smit

What does static mean in front of function. Like:

static void f();

I know what it means when function f is in a class, but when it's not
in class, what does that mean then?

Generally that it acquires internal linkage. Ie. it becomes "module
private".

--
Regards,

Ferdi Smit (M.Sc.)
Email: (e-mail address removed)
Room: C0.07 Phone: 4229
INS3 Visualization and 3D Interfaces
CWI Amsterdam, The Netherlands
 
V

Victor Bazarov

What does static mean in front of function. Like:

static void f();

I know what it means when function f is in a class, but when it's not
in class, what does that mean then?

It's been deprecated. The function's name is limited in scope to the file
in which it's defined. Now, to introduce a function whose name is not
visible outside its own translation unit, we use anonymous namespaces.

namespace {
void f();
}

And you should probably define it right there...

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top