Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2006

Tip: Looking for answers? Try searching our database.

differences in code, please explain

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Petded - 15 Jun 2006 08:35 GMT
Hi,

can anyone explain to me why

vc++ managed use this

s= gcnew Socket(
AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::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
adebaene@club-internet.fr - 15 Jun 2006 09:43 GMT
Petded a écrit :

> Hi,
>
[quoted text clipped - 11 lines]
>
> 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
Petded - 15 Jun 2006 12:50 GMT
Thanks

>Petded a écrit :
>
[quoted text clipped - 29 lines]
>Arnaud
>MVP - VC
Peter Ritchie - 16 Jun 2006 19:05 GMT
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;

?
Signature

http://www.peterRitchie.com/

> Petded a écrit :
>
[quoted text clipped - 29 lines]
> Arnaud
> MVP - VC
Arnaud Debaene - 16 Jun 2006 23:34 GMT
> Arnaud, you can't use "::", '.', or "->" in the same places (i.e. they're
> context sensitive), so *why not* consolotate them into one overridden
[quoted text clipped - 11 lines]
>  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
Ben Voigt - 19 Jun 2006 16:42 GMT
> Hi,
>
[quoted text clipped - 13 lines]
>
> 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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.