473,386 Members | 1,710 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,386 software developers and data experts.

"namespace" and "class"

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
3 1649
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jacek Dziedzic | last post by:
Is it valid to use a "using namespace foo" (as opposed to using foo::bar which I'm sure is legal) within a class declaration? My compiler rejects it, but I've been told it's valid. Can anyone...
5
by: SenthilSS | last post by:
My application produces XML Data files which have XML namespace qualified XML elements (nodes), but the namespace itself is not declared in the data file. My task is to read these data files in a...
0
by: maxim mat | last post by:
Hi I need to build client for web service. But when I'm using Visual Studio .NET to add Web Reference, I get error: "Custom tool error: Unable to import WebService/Schema. Unable to import...
0
by: kevin_g_frey | last post by:
Hello We have an internal tool that generates a series of .NET class wrappers for accessing our database entities. One of our database entities is called "System" so our correspond __gc class is...
48
by: mahurshi | last post by:
I am new to c++ classes. I defined this "cDie" class that would return a value between 1 and 6 (inclusive) It runs fine and gives no warnings during compilation. I was wondering if you guys...
3
by: nadeem_far | last post by:
Hello All, I have a couple of questions and I am not able to find them any where on internet. 1. We are using a third party class library which exposes a class with the name of "class". ...
14
by: Ronald S. Cook | last post by:
I'm just curious how you would handle this. In the cable industry, Comcast is referred to as an "MSO" (multiple systems operator) meaning they own many cable systems. Therefore a solution must be...
2
by: shalong | last post by:
Hi all, VS 2008 is complaining that HttpWebRequest class is not in System.Net namespace I have referenced System.Net and have coded "using System.Net" I think its a setup problem rather than a...
3
by: Matt | last post by:
Hi everyone, can someone point out the difference between defining a class with the public access modifier and just leaving it as it is (default in vs.net "class") I think that the default...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.