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 5 978
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
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
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
"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
<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 This discussion thread is closed Replies have been disabled for this discussion. Similar topics
4 posts
views
Thread by MS |
last post: by
|
13 posts
views
Thread by Blue |
last post: by
| |
7 posts
views
Thread by Karol R |
last post: by
| | | | | | | | | | | |