By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,171 Members | 980 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,171 IT Pros & Developers. It's quick & easy.

"namespace" and "class"

P: n/a
I have a question:

what differences are between:
namespace Mary {

int r = 5 ;

char m[r] ;

void print1() ;

}
and
class Mary {
private :
int r = 5 ;
char m[r] ;

public :
Mary();
~Mary() ;
void print1() ;
}
excluding "private", "public", contructor and destructor in "class Mary" ?
Generally: what differences are between using declaration of "namespace"
and "class" ?
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
In the class case, members m and r are not visible outside the class.
However, in the namespace case, m and r *are* visible to anyone
accessing the namespace.

Also, the namespace variant will create global m and r, the class case
has them as instance data.
Jul 23 '05 #2

P: n/a
This program does not work as as c++ doesnot support variable sizeof
arrays like that.

Athresh

Phil Staite <ph**@nospam.com> wrote in message news:<42**************@nospam.com>...
In the class case, members m and r are not visible outside the class.
However, in the namespace case, m and r *are* visible to anyone
accessing the namespace.

Also, the namespace variant will create global m and r, the class case
has them as instance data.

Jul 23 '05 #3

P: n/a
This program does not work as it has a variable array inside the
namespace which is neither supported in c or c++

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.