Hi All
I read a .cpp files,find that
static void fun(void){..... .}
int main()
{
..........
}
What does this static function mean?Is it the same as the static
function in a class?
Thanks 4 5303
dolphin a ¨¦crit :
I read a .cpp files,find that
static void fun(void){..... .}
int main()
{
.........
}
What does this static function mean?Is it the same as the static
function in a class?
Technically, this means the name of the function won't be exported so
you can reuse it in more than one compilation unit.
From the programmer point of view, this means the function won't be
called by tis name outside the compilation unit.
An alternative is to use an unnamed namespace.
Michael
On Nov 5, 4:57 pm, Michael DOUBEZ <michael.dou... @free.frwrote:
dolphin a écrit :
I read a .cpp files,find that
static void fun(void){..... .}
int main()
{
.........
}
What does this static function mean?Is it the same as the static
function in a class?
Technically, this means the name of the function won't be exported so
you can reuse it in more than one compilation unit.
From the programmer point of view, this means the function won't be
called by tis name outside the compilation unit.
An alternative is to use an unnamed namespace.
Michael
Do you mean you just can use this function in that cpp file?And you
cannt use it in another cpp file?
dolphin a écrit :
On Nov 5, 4:57 pm, Michael DOUBEZ <michael.dou... @free.frwrote:
>dolphin a écrit :
>>I read a .cpp files,find that static void fun(void){..... .} int main() { ......... } What does this static function mean?Is it the same as the static function in a class?
Technically, this means the name of the function won't be exported so you can reuse it in more than one compilation unit.
From the programmer point of view, this means the function won't be called by tis name outside the compilation unit.
An alternative is to use an unnamed namespace.
Do you mean you just can use this function in that cpp file?And you
cannt use it in another cpp file?
What I mean is that the name of the function is not exported in the
symbol table so you cannot link against it outside the cpp file it is
defined in.
That doesn't mean it cannot be used, you could use through is function
pointer by example. But not with its name. Try it out on an example.
main.cpp
-----------------------
extern int cu_function();
int main()
{
return cu_function();
}
cu.cpp
-----------------------
//uncomment static to see what happen
//static
int cu_function()
{
return 0;
}
-----------------------
Then
g++ main.cpp cu.cpp
Michael This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steve Richter |
last post by:
What does the "." mean in the following sql script stmts?
use
GO
if exists (select * from dbo.sysobjects where
id = object_id(N'.')
and OBJECTPROPERTY(id,N'IsUserTable') = 1)
drop table .
GO
|
by: RobertTG |
last post by:
Someone please translate the code below into English...
Particularly the indicated line
Thanks
function attachComment()
{
var aForms = document.getElementsByTagName("FORM");
for (var i = 0; i < aForms.length; i++)
{
|
by: allenj |
last post by:
DB21085I Instance "md" uses "32" bits and DB2 code release "SQL08012"
with level identifier "02030106".
Informational tokens are "DB2 v8.1.0.16", "s030508", "MI00048", and
FixPak "2". Product is installed at "/opt/IBM/db2/V8.1".
Red Hat AS
--------------------------------
what does this error mean?
SQL Error Code -443, SQL State 38553, Routine "SYSIBM.SQLCOLUMNS"
|
by: Larry David |
last post by:
Ok, first of all, let's get the obvious stuff out of the way. I'm an idiot. So please indulge me for a moment. Consider it an act of "community service"....
What does "64bit" mean to your friendly neighborhood C# programmer? The standard answer I get from computer sales people is: "It means that the CPU can process 64 bits of data at a time instead of 32." Ok... I guess I *kind* of understand what that means at an intuitive level, but what...
|
by: Heinrich Pumpernickel |
last post by:
what does this warning mean ?
#include <stdio.h>
int main()
{
long l = 100;
printf("l is %li\n", l * 10L);
| |
by: priyain |
last post by:
hello,
Can anyone explain me what is static function in c with example ?
also where it is used ?
|
by: loudking |
last post by:
Hello, all
I don't quite understand what does ((time_t)-1) mean when I execute
"man 2 time"
RETURN VALUE
On success, the value of time in seconds since the Epoch is
retu
rned.
On error, ((time_t)-1) is returned, and errno is set
|
by: dayanand50 |
last post by:
ii wanted to know what is static function in java and how to declare it
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |