Re: Simple Question: Pointers as Arguments
Quote:
Originally Posted by
TheGreatCthulhu
P.S. I think the creation of C# was, in fact, influenced by Java.
Many would rather have it that C# is a rip-off of Java. :)
Back in 1995 when Java was introduced by Sun everybody was behind Java including Microsoft and Apple. Steven Jobs bragged that Apple would have the best Java on the planet while Microsoft actually had it.
Then the relationship between Sun and Microsoft turned sour. The reason was that Microsoft wanted to tweak Java so that programs compiled with the Microsoft compiler would run on Windows only. This developed into an ugly legal war that ended with Microsoft dropping Java and later paying damages to Sun.
Instead Microsoft came up with C# that initially was more or less a Java clone. But over the years lots of new features were introduced in C# unlike Java which pretty much stayed the same. So today they differ quite a lot apart from the fact that both are based on the same general principles.
Re: Simple Question: Pointers as Arguments
About multiple pointer declarations - I think I remember now I have read about it long time ago.
Anyway, here's the source of confusion - this is from MSDN article called "Pointer types (C# Programming Guide) ":
Code:
int* p1, p2, p3; // Ok
int *p1, *p2, *p3; // Invalid in C#
What I don't like in the standard used by C++ is that a token *name has a different meaning in different contexts (it means "pointer" in a declaration, and "value pointed by" otherwise). It's not a major issue, but it can lead to some unnecessary confusion.
To nuzzle:
So the story behind Java and C# is a sort of a legal soap opera. Funny :) :) :)
But C# turned out rather good, and I love it.
P.S. Oh God, I just tried to CTRL+SPACE a word here.
Re: Simple Question: Pointers as Arguments
One more thing: shouldn't karnavor's MyFunction(...) as it is defined in the first post also cause a memory leak? Once the function exits, the newly created data is lost; since, although the data is passed by reference, the pointer itself is passed by value, right?
Re: Simple Question: Pointers as Arguments
Quote:
Originally Posted by
TheGreatCthulhu
To nuzzle:
So the story behind Java and C# is a sort of a legal soap opera. Funny :) :) :)
But C# turned out rather good, and I love it.
For many it was a matter of life or death. This happened at the height of Microsoft bashing and Sun was considered the good white knight in shining armour standing up to Microsoft, the very incarnation of everything evil on earth. So when Sun took the money and made up with Microsoft emotions boiled over. Many just couldn't stand the sight of Scott McNeally shaking hands with Bill Gates, smiling as if they were longtime buddies. Some high-ranking Sun employees felt so betrayed they even left the company. I have a feeling this may have contributed substantially to Sun's downfall.
Anyway, I prefer Java for the simple reason it's portable. C# is more advanced today but unfortunately it's limited to Windows. There's an interesting alternative to both Java and C# and that's C++/CLI. If it was ported to the Java VM it probably would be my favourite. C++/CLI basically is classic C++ with the "managed" features of Java and C# on top.
Everything considered, my favourite is C++. Especially with Qt now licenced under LGPL and especially with the new features of the new standard coming soon.
Re: Simple Question: Pointers as Arguments
Quote:
Originally Posted by TheGreatCthulhu
Interesting - although I don't like this standard (makes my reasoning fail, or at least seem awkward); but, this is well established, so it is certainly something for a programmer to bear in mind.
It is mentioned in Stroustrup's answer to the FAQ: Is ``int* p;'' right or is ``int *p;'' right?
Re: Simple Question: Pointers as Arguments
Quote:
Originally Posted by
nuzzle
Anyway, I prefer Java for the simple reason it's portable. C# is more advanced today but unfortunately it's limited to Windows.
Well, there's Mono, but that's pretty much a hack to get .NET running on non-Windows systems, not true cross-platform capability.
Quote:
There's an interesting alternative to both Java and C# and that's C++/CLI. If it was ported to the Java VM it probably would be my favourite. C++/CLI basically is classic C++ with the "managed" features of Java and C# on top.
That's surprising. Again, I haven't had reason to familiarize myself with .NET at all yet, but the general consensus seemed to be that C++/CLI was a kludged-together Frankenstein which does neither .NET nor native coding very well, while trying to do both.
Re: Simple Question: Pointers as Arguments
Quote:
Originally Posted by
laserlight
Thanks for that.
Stroustrup's site is like a programmer's bible, everyone should have it bookmarked (Bjarne Stroustrup's homepage).
I followed your link the day you posted it, but I didn't intend to write any new posts, however now I feel that I should share this, since novice programmers, but not just them, could greatly benefit from it. Especially C++ programmers.
Quote:
Originally Posted by
nuzzle
Everything considered, my favourite is C++. Especially [...] with the new features of the new standard coming soon.
You mean C++0x?
Interesting. Check out what Stroustrup says on the same site: "Surprisingly, C++0x feels like a new language".
(Bjarne Stroustrup's C++0x FAQ: What do you think of C++0x?)