[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Access to a global string?

Phil Moors wrote:

> Would I decare static char foo[255] as a public member of myApp and then pass a
> pointer to the dialogs?

Close. If you declare myApp::foo as static, then you do not need 
to pass the pointer. Anything in your app can have access to it

A safer C++ way is to make myApp::foo private , then provide
public interface functions like string myApp::getfoo() const, 
and void myApp::setfoo(const string&) for reading and manipulating the
data. That way in your interfaces you can catch nastys like clients 
overflowing your string, or writing stupid data and such.


Reply to: