472,960 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

differences in code, please explain

Hi,

can anyone explain to me why

vc++ managed use this

s= gcnew Socket(
AddressFamily::InterNetwork,SocketType::Stream,Pro tocolType::Tcp );

whereas c# use this

s = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);

Why c++ uses :: and what does it represent, a why c# just uses a .

Also C# only ever uses a . whereas sometimes c++ uses -> instead of ::

thanks for any help


Jun 15 '06 #1
5 1063

Petded a écrit :
Hi,

can anyone explain to me why

vc++ managed use this

s= gcnew Socket(
AddressFamily::InterNetwork,SocketType::Stream,Pro tocolType::Tcp );

whereas c# use this

s = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);

Why c++ uses :: and what does it represent, a why c# just uses a .
In C++, "::" is used as the scope resolution operator for namespaces
and static members, whereas "." is used to derefrence a member of an
actual object. Also, "->" is used to dereference a pointer (if you need
to know the difference between a pointer, an object and a reference, I
suggest you pick up a good C++ introductory book, because newsgroup are
not the good place to learn those things).

Also C# only ever uses a . whereas sometimes c++ uses -> instead of ::


Yep, and IMHO C# is wrong to use the same syntax to do different things
: it makes things a little simplier for beginners, but at the end ot
day it messes up the whole thing.

Arnaud
MVP - VC

Jun 15 '06 #2
On 15 Jun 2006 01:43:53 -0700, ad******@club-internet.fr wrote:

Thanks


Petded a écrit :
Hi,

can anyone explain to me why

vc++ managed use this

s= gcnew Socket(
AddressFamily::InterNetwork,SocketType::Stream,Pro tocolType::Tcp );

whereas c# use this

s = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);

Why c++ uses :: and what does it represent, a why c# just uses a .


In C++, "::" is used as the scope resolution operator for namespaces
and static members, whereas "." is used to derefrence a member of an
actual object. Also, "->" is used to dereference a pointer (if you need
to know the difference between a pointer, an object and a reference, I
suggest you pick up a good C++ introductory book, because newsgroup are
not the good place to learn those things).

Also C# only ever uses a . whereas sometimes c++ uses -> instead of ::


Yep, and IMHO C# is wrong to use the same syntax to do different things
: it makes things a little simplier for beginners, but at the end ot
day it messes up the whole thing.

Arnaud
MVP - VC


Jun 15 '06 #3
Arnaud, you can't use "::", '.', or "->" in the same places (i.e. they're
context sensitive), so *why not* consolotate them into one overridden
"operator".

Is

a.b();
a.c.d();
a.e variable;

really less clear than:

a::b();
a::c->d();
a::e variable;

?
--
http://www.peterRitchie.com/
"ad******@club-internet.fr" wrote:

Petded a écrit :
Hi,

can anyone explain to me why

vc++ managed use this

s= gcnew Socket(
AddressFamily::InterNetwork,SocketType::Stream,Pro tocolType::Tcp );

whereas c# use this

s = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);

Why c++ uses :: and what does it represent, a why c# just uses a .


In C++, "::" is used as the scope resolution operator for namespaces
and static members, whereas "." is used to derefrence a member of an
actual object. Also, "->" is used to dereference a pointer (if you need
to know the difference between a pointer, an object and a reference, I
suggest you pick up a good C++ introductory book, because newsgroup are
not the good place to learn those things).

Also C# only ever uses a . whereas sometimes c++ uses -> instead of ::


Yep, and IMHO C# is wrong to use the same syntax to do different things
: it makes things a little simplier for beginners, but at the end ot
day it messes up the whole thing.

Arnaud
MVP - VC

Jun 16 '06 #4

"Peter Ritchie" <PR****@newsgroups.nospam> a écrit dans le message de news:
6E**********************************@microsoft.com...
Arnaud, you can't use "::", '.', or "->" in the same places (i.e. they're
context sensitive), so *why not* consolotate them into one overridden
"operator".

Is

a.b();
a.c.d();
a.e variable;

really less clear than:

a::b();
a::c->d();
a::e variable;


I believe so, because when reading code that you don't know, it make clear
wether "a" is a namespace or a class, an object instance or a pointer, which
is not always immediatly obvious...

Arnaud
MVP - VC
Jun 16 '06 #5

<Petded> wrote in message news:m7********************************@4ax.com...
Hi,

can anyone explain to me why

vc++ managed use this

s= gcnew Socket(
AddressFamily::InterNetwork,SocketType::Stream,Pro tocolType::Tcp );

whereas c# use this

s = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);

Why c++ uses :: and what does it represent, a why c# just uses a .

Also C# only ever uses a . whereas sometimes c++ uses -> instead of ::
Others have explained to you the difference... but this statement is not
true. C# also uses -> to for pointer-dereferencing member access.

In both languages, with p being a pointer (compile error otherwise):

p->val

is exactly equivalent to

(*p).val

thanks for any help

Jun 19 '06 #6

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

Similar topics

4
by: MS | last post by:
Just a general question here re VBA. Can anyone explain the differences between "!" and "." when refering to a control? eg Me!TxtBox and Me.TxtBox. What is difference between "+" and "&"...
13
by: Blue | last post by:
Hi , Can any one please let me explain me the diffrences between "open"/ "fopen" or "read"/"fread" or "write/fwrite". I know that "open" /"read" / "write" are system calls and "fopen"...
0
by: induriprakash | last post by:
Hi, We are working on a scientifical related product which is most sensitive towards mathematical functions (even 7th decimal place chang can cause considereble differences in the output values)....
7
by: Karol R | last post by:
Can anyone please explain me main differences between relational DB and warehouse (Point me to web site) ? Apart from theoretical differences I would like to know how Warehouse DB is updated ?...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.