Re: How to put const into function pointer?
Immortal_Nephi@hotmail.com wrote:
[..]
Can you please say if it is ok to place "Obj obj;" inside main()
function or global scope?
If you place it in the 'main' function, you will have to pass it as the
argument to any of the functions where it's needed. If it's global, the
functions can gain access to it directly. It's up to you to decide what
type of access you want.
> "Obj" is a lifetime throughout program so
all classes and functions can access "Obj" directly. It is ideal if I
want to use only one instance in this throughout program.
You can run program (such as .exe) three times. This program has
three separated memory. "Obj" has its own copy in global scope
throughout program. It would be nice to create static library or
dynamic linked library so "Obj" can be reused each throughout program.
What do you think?
I am not entirely sure what you're trying to explain here. You want the
object to survive between different runs of the program? Then you need
to read about "persistence". Essentially you want to store the object
somewhere (like a file on disk) and read it from that file when you
start again. Once more, I am not sure if that's what you're asking about.
I am sorry to place void between (). I am not aware of C writing. I
need to learn all C++ rules. How can I get rules?
It's OK to place 'void', it's just a bad habit. It's a question of
style, nothing more. There is a good book on style, I believe Herb
Sutter co-authored it with somebody. It's titled "Exceptional C++
Style" or something like that. Look it up. Although I am not sure that
'void' between parentheses is mentioned in that book. :-)
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask