473,395 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Pass by Reference Function Question

I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline. I define variables and functions in the global scope. The global
variables and global functions are hidden to prevent from accessing by the
programmers. All global functions share global variables.
Only very few global functions are allowed to be reusability for the
programmers to use. Few global functions access most hidden functions
during the time execution.
My question is -- do you think that pass by reference is really
necessary? Pass by reference is necessary unless you want to reuse function
with the choice of global / local variables. Please advise.

--

Yours Truly,
Bryan Parkoff
Jun 27 '08 #1
12 2985
Bryan Parkoff wrote:
I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline. I define variables and functions in the global scope. The
global variables and global functions are hidden to prevent from
accessing by the programmers. All global functions share global
variables. Only very few global functions are allowed to be
reusability for the programmers to use. Few global functions access
most hidden functions during the time execution.
That sounds like a very bad design. No offence.
My question is -- do you think that pass by reference is really
necessary? Pass by reference is necessary unless you want to reuse
function with the choice of global / local variables. Please advise.
You need a good book on design and some time to digest it. I am not
really sure what to recommend. "Advanced C++" by Coplien? Dated.
"Multiparadigm Design for C++" by him? Maybe. "Modern C++ Design"
by Alexandrescu? "Large-Scale C++ Software Design" by Lakos? <shrug>

If you want more OOD theory, look for Grady Booch (and ask in the
comp.object newsgroup).

Most of what I've read and been taught says that global data should be
avoided. So, if you start with that premise, passing objects to your
functions (either by pointer or by reference) becomes a necessity.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #2
On Apr 11, 3:24 pm, "Bryan Parkoff" <nos...@nospam.comwrote:
I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline. I define variables and functions in the global scope.
OK
The global
variables and global functions are hidden to prevent from accessing by the
programmers.
Then they aren't global are they?
What means did you use to "hide" them?

All global functions share global variables.
OK
Only very few global functions are allowed to be reusability for the
programmers to use.
What do you mean?
You have global functions that you don't want anyone to call? They
probably shouldn't be global then.

Few global functions access most hidden functions
during the time execution.
I thought the global functions were hidden themselves from what you
said earlier...
So, you have global "hidden" functions (I don't know how) calling
other global "hidden" functions?

My question is -- do you think that pass by reference is really
necessary?
Necessary for what?
What are you trying to do? show some source code.

Pass by reference is necessary unless you want to reuse function
with the choice of global / local variables.
What? I don't know what you are talking about, but no. There is no
requirement to pass by reference based on global functions or
variables or lack thereof.
Jun 27 '08 #3
On Apr 11, 3:24 pm, "Bryan Parkoff" <nos...@nospam.comwrote:
> I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline. I define variables and functions in the global scope.

OK
I see you understand now.
>The global
variables and global functions are hidden to prevent from accessing by
the
programmers.

Then they aren't global are they?
What means did you use to "hide" them?
Well, you can make one of two choice -- global object or local object.
The local object is ideal for class. You can always bind local variable and
local function inside class. I have chosen to use global object. I agree
that global variable should be avoided unless you put global object inside
namespace for better readability. Global object has concern of performance
issue than local object like class. Anyway...
> All global functions share global variables.

OK
> Only very few global functions are allowed to be reusability for the
programmers to use.

What do you mean?
You have global functions that you don't want anyone to call? They
probably shouldn't be global then.
You call public global function. Then public global function is in turn
to call hidden global functions. I do not want the programmers to see
hidden global functions and they are allowed to use global object by running
public global function.
>Few global functions access most hidden functions
during the time execution.

I thought the global functions were hidden themselves from what you
said earlier...
So, you have global "hidden" functions (I don't know how) calling
other global "hidden" functions?

>My question is -- do you think that pass by reference is really
necessary?

Necessary for what?
What are you trying to do? show some source code.

>Pass by reference is necessary unless you want to reuse function
with the choice of global / local variables.

What? I don't know what you are talking about, but no. There is no
requirement to pass by reference based on global functions or
variables or lack thereof.
Let me give you sample code. It helps you to understand better. You
can see that pass by reference is not necessary because all hidden functions
share global variable.

// Global object
namespace Object
{
static int a = 0; // hidden global variable
static int b = 0; // hidden global variable
static int c = 0; // hidden global variable

static void Modify1 (void); // hidden global function
static void Modify2 (void); // hidden global function
static void Modify3 (void); // hidden global function
void Run_Object (void); // public global function

void Modify1 (void)
{
a += 2;
b += 4;
c = a * b;
}

void Modify2 (void)
{
a *= 5;
b *= 10;
c = a - b;
}

void Modify3 (void)
{
a = b / c;
b = 0;
c = 0;
}

void Run_Object (void)
{
Modify1();
Modify2();
Modify3();
}
}

// end of header

#include "object.h" // above code

int main (void)
{
// do something...
Object::Run_Object(); // Run fine for all hidden functions.

Object::Modify1 (); // Error Time Compile -- you can't access hidden
global functions.
a = 5; // Time Compile runs fine unless you use global variable -- a
outside main function on this source like main.cpp
Object::a = 10; // Error Time Compile -- you can't access hidden global
variable
return 0;
}

You can see that namespace is ideal for readability because sometimes
global variable has the same name in both source codes. It guards against
overwritten accidently.
Please advise.

Yours Truly,
Bryan Parkoff
Jun 27 '08 #4
On Apr 11, 5:00 pm, "Bryan Parkoff" <nos...@nospam.comwrote:
On Apr 11, 3:24 pm, "Bryan Parkoff" <nos...@nospam.comwrote:
I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline. I define variables and functions in the global scope.
OK

I see you understand now.
The global
variables and global functions are hidden to prevent from accessing by
the
programmers.
Then they aren't global are they?
What means did you use to "hide" them?

Well, you can make one of two choice -- global object or local object.
The local object is ideal for class. You can always bind local variable and
local function inside class. I have chosen to use global object. I agree
that global variable should be avoided unless you put global object inside
namespace for better readability. Global object has concern of performance
issue than local object like class. Anyway...
All global functions share global variables.
OK
Only very few global functions are allowed to be reusability for the
programmers to use.
What do you mean?
You have global functions that you don't want anyone to call? They
probably shouldn't be global then.

You call public global function. Then public global function is in turn
to call hidden global functions. I do not want the programmers to see
hidden global functions and they are allowed to use global object by running
public global function.
Few global functions access most hidden functions
during the time execution.
I thought the global functions were hidden themselves from what you
said earlier...
So, you have global "hidden" functions (I don't know how) calling
other global "hidden" functions?
My question is -- do you think that pass by reference is really
necessary?
Necessary for what?
What are you trying to do? show some source code.
Pass by reference is necessary unless you want to reuse function
with the choice of global / local variables.
What? I don't know what you are talking about, but no. There is no
requirement to pass by reference based on global functions or
variables or lack thereof.

Let me give you sample code. It helps you to understand better. You
can see that pass by reference is not necessary because all hidden functions
share global variable.

// Global object
namespace Object
{
static int a = 0; // hidden global variable
static int b = 0; // hidden global variable
static int c = 0; // hidden global variable

static void Modify1 (void); // hidden global function
static void Modify2 (void); // hidden global function
static void Modify3 (void); // hidden global function
void Run_Object (void); // public global function

void Modify1 (void)
{
a += 2;
b += 4;
c = a * b;
}

void Modify2 (void)
{
a *= 5;
b *= 10;
c = a - b;
}

void Modify3 (void)
{
a = b / c;
b = 0;
c = 0;
}

void Run_Object (void)
{
Modify1();
Modify2();
Modify3();
}

}

// end of header

#include "object.h" // above code

int main (void)
{
// do something...
Object::Run_Object(); // Run fine for all hidden functions.

Object::Modify1 (); // Error Time Compile -- you can't access hidden
global functions.
a = 5; // Time Compile runs fine unless you use global variable -- a
outside main function on this source like main.cpp
Object::a = 10; // Error Time Compile -- you can't access hidden global
variable
return 0;

}

You can see that namespace is ideal for readability because sometimes
global variable has the same name in both source codes. It guards against
overwritten accidently.
Please advise.

Yours Truly,
Bryan Parkoff

Oh my goodness where to begin...

Do not write implementation in header files. Write it in .cpp files
Your source is obviously not what you ran, because the compiler gives
no such error: "you can't access hidden global variable"

Yes, passing anything at all, by reference or value, is not necessary
in this example code, because the variables in question are global to
the namespace in which the functions that use them, belong to. Passing
them by reference is not necessary because they are also primitive
types. Passing them by reference is also not necessary because
modifications made to them inside the function change the variables
values outside the function, since they are global. Had they been UDTs
passing by reference or const reference may have been preferable. Had
they belonged to another object or been declared within function body,
passing by reference may have been necessary.

I see no reason at all that this entire namespace can't be neatly made
into a class. Why are you making everything global exactly?

Also, are you sure you know what you are doing with the "static"
keyword here?

Jun 27 '08 #5
Bryan Parkoff wrote:
[..]
Let me give you sample code. It helps you to understand better. You
can see that pass by reference is not necessary because all
hidden functions share global variable.

// Global object
namespace Object
{
static int a = 0; // hidden global variable
static int b = 0; // hidden global variable
static int c = 0; // hidden global variable

static void Modify1 (void); // hidden global function
static void Modify2 (void); // hidden global function
static void Modify3 (void); // hidden global function
You keep using the word "hidden" as if it is a mantra. How are
those variables and functions *hidden*? I can see them here
just fine, and so can a compiler.
void Run_Object (void); // public global function

void Modify1 (void)
{
a += 2;
b += 4;
c = a * b;
}

void Modify2 (void)
{
a *= 5;
b *= 10;
c = a - b;
}

void Modify3 (void)
{
a = b / c;
b = 0;
c = 0;
}

void Run_Object (void)
{
Modify1();
Modify2();
Modify3();
}
}

// end of header

#include "object.h" // above code

int main (void)
Please drop those "void" in parentheses. Looks so C, so last
century. Don't put anything where nothing is expected.
{
// do something...
Object::Run_Object(); // Run fine for all hidden functions.
I have a problem with your comments. I don't get the errors where
you claim to have some, and I do get the error on the 'a = 5' line
where you say "runs fine"...
Object::Modify1 (); // Error Time Compile -- you can't access
hidden global functions.
a = 5; // Time Compile runs fine unless you use global variable --
a outside main function on this source like main.cpp

I don't get the "fine" above, 'a' is undefined.
Object::a = 10; // Error Time Compile -- you can't access hidden
global variable
I get no error.
return 0;
}

You can see that namespace is ideal for readability because
sometimes global variable has the same name in both source codes. It
guards against overwritten accidently.
Huh?
Please advise.
What is it you'd like us to advise on? Could you please put it in
a form of a question?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #6
"Christopher" <cp***@austin.rr.comwrote in message
news:8b**********************************@8g2000hs u.googlegroups.com...
On Apr 11, 5:00 pm, "Bryan Parkoff" <nos...@nospam.comwrote:
On Apr 11, 3:24 pm, "Bryan Parkoff" <nos...@nospam.comwrote:
I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline. I define variables and functions in the global scope.
OK

I see you understand now.
>The global
variables and global functions are hidden to prevent from accessing by
the
programmers.
Then they aren't global are they?
What means did you use to "hide" them?

Well, you can make one of two choice -- global object or local
object.
The local object is ideal for class. You can always bind local variable
and
local function inside class. I have chosen to use global object. I
agree
that global variable should be avoided unless you put global object
inside
namespace for better readability. Global object has concern of
performance
issue than local object like class. Anyway...
> All global functions share global variables.
OK
> Only very few global functions are allowed to be reusability for
the
programmers to use.
What do you mean?
You have global functions that you don't want anyone to call? They
probably shouldn't be global then.

You call public global function. Then public global function is in
turn
to call hidden global functions. I do not want the programmers to see
hidden global functions and they are allowed to use global object by
running
public global function.
>Few global functions access most hidden functions
during the time execution.
I thought the global functions were hidden themselves from what you
said earlier...
So, you have global "hidden" functions (I don't know how) calling
other global "hidden" functions?
>My question is -- do you think that pass by reference is really
necessary?
Necessary for what?
What are you trying to do? show some source code.
>Pass by reference is necessary unless you want to reuse function
with the choice of global / local variables.
What? I don't know what you are talking about, but no. There is no
requirement to pass by reference based on global functions or
variables or lack thereof.

Let me give you sample code. It helps you to understand better. You
can see that pass by reference is not necessary because all hidden
functions
share global variable.

// Global object
namespace Object
{
static int a = 0; // hidden global variable
static int b = 0; // hidden global variable
static int c = 0; // hidden global variable

static void Modify1 (void); // hidden global function
static void Modify2 (void); // hidden global function
static void Modify3 (void); // hidden global function
void Run_Object (void); // public global function

void Modify1 (void)
{
a += 2;
b += 4;
c = a * b;
}

void Modify2 (void)
{
a *= 5;
b *= 10;
c = a - b;
}

void Modify3 (void)
{
a = b / c;
b = 0;
c = 0;
}

void Run_Object (void)
{
Modify1();
Modify2();
Modify3();
}

}

// end of header

#include "object.h" // above code

int main (void)
{
// do something...
Object::Run_Object(); // Run fine for all hidden functions.

Object::Modify1 (); // Error Time Compile -- you can't access hidden
global functions.
a = 5; // Time Compile runs fine unless you use global variable -- a
outside main function on this source like main.cpp
Object::a = 10; // Error Time Compile -- you can't access hidden
global
variable
return 0;

}

You can see that namespace is ideal for readability because sometimes
global variable has the same name in both source codes. It guards
against
overwritten accidently.
Please advise.

Yours Truly,
Bryan Parkoff
Christopher,
Oh my goodness where to begin...
Thank you for your comment.
Do not write implementation in header files. Write it in .cpp files
Your source is obviously not what you ran, because the compiler gives
no such error: "you can't access hidden global variable"
I agree. I always declare variables and functions in the header code
and I always define variable and functions in the source code. It would
help to debug a lot better. After you complete designing both header code
and source code, you will be able to create static library or DLL library.
Then, source code is not necessary. You can always use header code and it
will access to "LIB" or "DLL" file at compile time.
Yes, passing anything at all, by reference or value, is not necessary
in this example code, because the variables in question are global to
the namespace in which the functions that use them, belong to. Passing
them by reference is not necessary because they are also primitive
types. Passing them by reference is also not necessary because
modifications made to them inside the function change the variables
values outside the function, since they are global. Had they been UDTs
passing by reference or const reference may have been preferable. Had
they belonged to another object or been declared within function body,
passing by reference may have been necessary.
I understand.
I see no reason at all that this entire namespace can't be neatly made
into a class. Why are you making everything global exactly?
According to my performance test, global variables and global functions
are running faster than local variable and local function inside class. You
don't need to use a pointer to access global variable or global function.
You create a class. You define local variable and local function inside
class. The class requires a pointer to access local variable or local
function inside class. It may be slow because extra x86 instruction has to
be added to read memory address and then locate value in the memory.
Also, are you sure you know what you are doing with the "static"
keyword here?
Yes, I understand "static" keyword. It has two different definitions.
If you have same variable name on the global scope and local scope, you put
static inside function. Local variable inside function can modify global
variable outside of function. This way, you exit function, you won't lose
local variable to be placed in global variable. It is fine. I don't use
this feature.
Another definition for static is internal linkage. All global variables
and global functions have static keyword so they are inside internal
linkage. The global variable and global function using internal linkage on
the one header code is never available to all source codes unless you want
to use public function (you put extern keyword for public) in turn to access
hidden function. It is good design.
Please tell me what you think how to design object better -- use global
object for performance reason or local object for readability and reduce
bugs.

Yours Truly,
Bryan Parkoff
Jun 27 '08 #7
Bryan Parkoff asked:
I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline.
Ewww. Don't do that. If these functions are all doing nearly
the same thing (as I very much suspect), replace those 4000
functions with maybe 7 or 13 or 21 functions taking arguments
(passed by value or by reference, maybe returning a value and
maybe not, as the problem demands) to configure their behavior.

The whole idea of functions is STRUCTURE. That means top-level
functions call mid-level functions, and mid-level functions
call bottom-level functions. Having 4000 tiny, nearly-identical
bottom-level functions is a design nightmare.
I define variables and functions in the global scope.
Don't define variables at the global scope. Period.
The global variables and global functions are hidden to prevent
from accessing by the programmers. All global functions share
global variables.
I don't see how you can make global variables "hidden",
unless you make them file-static, so that only one translation
unit sees them.

If you need data hiding (encapsulation), define your objects
either on the stack (local, "auto") in functions, or dynamically
(using new and delete).

You can still allow one function to have read/write access to
local variables in another function by passing arguments by
non-const reference, like so:

void function2 (double & asdf) // NON-CONST REF!!!!!
{
asdf *= 2.0; // alters "trouble" in function1 below
return;
}

int function1 (void)
{
double trouble = 47;
function2(trouble); // double trouble (pardon pun)
std::cout << trouble << std::endl; // prints 94
return 42;
}
Only very few global functions are allowed to be reusability for the
programmers to use. Few global functions access most hidden functions
during the time execution.
My question is -- do you think that pass by reference is really
necessary? Pass by reference is necessary unless you want to reuse function
with the choice of global / local variables. Please advise.
Passing by non-const reference is the only way I know of that
one function can alter local variables in another function.
I use it a lot in my C++ programming. I try for ZERO global
variables. I often don't quite make it, electing to have
2 or 3 global variables, if they truly are used by a lot of
different functions. But that's really just laziness on my
part; it *could* all be done with non-const refs instead.

--
Cheers,
Robbie Hatley
lonewolf aatt well dott com
www dott well dott com slant user slant lonewolf slant
Jun 27 '08 #8
Robbie Hatley wrote:
Bryan Parkoff asked:
> I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline.

Ewww. Don't do that. If these functions are all doing nearly
the same thing (as I very much suspect), replace those 4000
functions with maybe 7 or 13 or 21 functions taking arguments
(passed by value or by reference, maybe returning a value and
maybe not, as the problem demands) to configure their behavior.
Where did he say they were doing nearly the same thing?

There's nothing wrong with using lots of small function if they make the
code clearer.

--
Ian Collins.
Jun 27 '08 #9
>> static int a = 0; // hidden global variable
>
Both a named namespace and file scope rarely makes sense.

To declare an identifier with external binding and
file scope, in C++, an anonymous namesspace is used:

namespace { int a = 0; }

»static« was used in C for this purpose, but is
obsolecent in C++.
If you write C source code, you always want most functions to be
invisible inside one header and source code using internal linkage. It is
best to guard these functions. It is ideal when you make to design a chip.
You do not want people to do reverse engineering to see inside chip and draw
schematic.
Then, why do you claim **static** keyword to be obsolete for both global
variables and global functions? I ask you please provide me an example of
your source code in C++. Please do not tell me if I have to use class. I
do not want to use a pointer to access memory address and locate variable
and function inside class. It is slower than global function without
pointer according to my performance test.
It is why I try to find some ways how to design object better on global
slope instead of local slope like class.
It is a bad practice to write a huge function with about 50 - 1,000
lines. It is too complex and difficult time to do debugging. Write very
small hundred or thousand functions with 5 - 20 lines. Be very simple
instead of complex. Add inline to all small functions. You can always put
some small sub-functions into one function. The C++ Compiler can decide to
put piece of sub-functions together into one big function. It can decide to
use peformance or small codes without inline.
Maybe, you should use **static** inside function body. This way, you
always avoid modifying global variable. Use local variable to test inside
function body. You decide to store local variable into global variable by
adding static. I think pass by reference is not good idea because you might
accidently overwrite global variable unless you know sure to be avoided.

Yours Truly,
Bryan Parkoff
Jun 27 '08 #10
"Bryan Parkoff" <no****@nospam.comwrote in
news:47***********************@roadrunner.com:
I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline. I define variables and functions in the global scope. The
global variables and global functions are hidden to prevent from
accessing by the programmers. All global functions share global
variables.
Only very few global functions are allowed to be reusability for
the
programmers to use. Few global functions access most hidden functions
during the time execution.
My question is -- do you think that pass by reference is really
necessary? Pass by reference is necessary unless you want to reuse
function with the choice of global / local variables. Please advise.
Parameter pass by reference is usually discussed as opposed to passing by
value, but it seems you are discussing it as opposed to avoiding any
parameters at all (note also that passing by reference might be slower
for small parameter types than passing by value).
That said, if your program works fine with only global variables, then
this shows:

- there can be only 1 instance of data state at any time
- your functions are not reentrant
- your functions are not usable in a multithreaded environment

In other words, the problem your program solves appears to be very
simple. The C++ language was invented for dealing with much more
complicated problem domains. For starters, different object states are
commonly encapsulated in classes and multiple instances (objects) of a
given class are created at the same time.

In essence, I think your question shold be translated to:

"My program solves a very simple real life problem and does it fine. Is
it necessary to use any more complicated methods designed for more
complicated software architectures in my simple program?"

Answering this question is easy (and honestly there seems to be no need
to use C++ language at all!), but the real question is different: do you
want to extend your program to do a bit more or a bit differently in the
future?

HTH
Paavo
Jun 27 '08 #11
Bryan Parkoff wrote:
>>> static int a = 0; // hidden global variable

Both a named namespace and file scope rarely makes sense.

To declare an identifier with external binding and
file scope, in C++, an anonymous namesspace is used:

namespace { int a = 0; }

»static« was used in C for this purpose, but is
obsolecent in C++.

If you write C source code, you always want most functions to be
invisible inside one header and source code using internal linkage. It is
best to guard these functions. It is ideal when you make to design a
chip. You do not want people to do reverse engineering to see inside chip
and draw schematic.
Then, why do you claim **static** keyword to be obsolete for both
global
variables and global functions?
Because for this you use anonymous namespaces, as multiple people have
already pointed out.
I ask you please provide me an example of
your source code in C++. Please do not tell me if I have to use class. I
do not want to use a pointer to access memory address and locate variable
and function inside class. It is slower than global function without
pointer according to my performance test.
You keep repeating that, but have you actually really tried it?

The following code:
class dummy {
public:
int a;
int b;
void set() { a = 5; b = 6; };
};
namespace {
int a;
int b;
dummy c;
};
void f1()
{
a = 5;
b = 6;
}
void f2()
{
c.set();
}

produces on IA32 with g++4.2 -O3 -Wall -fomit-frame-pointer:

_Z2f1v:
movl $5, _ZN37_GLOBAL__N_static.C_00000000_D9D9A4DE1aE
movl $6, _ZN37_GLOBAL__N_static.C_00000000_D9D9A4DE1bE
ret

_Z2f2v:
movl $5, _ZN37_GLOBAL__N_static.C_00000000_D9D9A4DE1cE
movl $6, _ZN37_GLOBAL__N_static.C_00000000_D9D9A4DE1cE+4
ret

That is exactly the same code for the "global variables" version and
the "class" version. Of course, if you don't use inline methods, there will
be use of a this pointer, but I have a hard time imagining an application
where this makes any significant difference.

And if I understand the question in your first post (which I doubt): then it
will be better to only pass *one* "this" pointer than references (which are
probably implemented as pointers) to *multiple* variables. Just use
classes.
Jun 27 '08 #12
Stefan Ram wrote:
"Bryan Parkoff" <no****@nospam.comwrites:
>>»static« was used in C for this purpose, but is
obsolecent in C++.
Then, why do you claim **static** keyword to be obsolete for both
global

In C++, »static« is only obsolescent if it is used to indicate
internal linkage, because in C++, an anonymous namespace is
intended to be used for this purpose.
That is simply not true. Items declared in an anonymous namespace
have *external linkage*. It's the name (which is supposedly mangled
in an undocumented way) that makes them impossible to be referred to
from another module, not the absence of an external name. If you
want to hide the name altogether, you need to declare the object
_static_, which will give it a local name.
Other uses of »static« are not deemed obsolescent.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
3
by: TeejB | last post by:
Hi all, Quick question: If I have a function which populates a large array (ie. reading rowsets), is it better to pass in a reference to a variable to accept the data, or should I just create,...
14
by: xdevel | last post by:
Hi, I need your help because I don't understand very well this: in C arguments are passed by-value. The function parameters get a copy of the argument values. But if I pass a pointer what really...
14
by: Abhi | last post by:
I wrote a function foo(int arr) and its prototype is declared as foo(int arr); I modify the values of the array in the function and the values are getting modified in the main array which is...
10
by: Robert Dailey | last post by:
Hi, I noticed in Python all function parameters seem to be passed by reference. This means that when I modify the value of a variable of a function, the value of the variable externally from the...
6
by: lisp9000 | last post by:
I've read that C allows two ways to pass information between functions: o Pass by Value o Pass by Reference I was talking to some C programmers and they told me there is no such thing as...
11
by: venkatagmail | last post by:
I have problem understanding pass by value and pass by reference and want to how how they are or appear in the memory: I had to get my basics right again. I create an array and try all possible...
9
by: raylopez99 | last post by:
I'm posting this fragment from another thread to frame the issue clearer. How to pass an object to a function/method call in C# that will guarantee not to change the object?* In C++, as seen...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.