View Full Version : Coming from a C# background, looking to start in C++
Aug 27, 2007, 03:32 PM
Can anyone recommend a good starting place for me? I have developed in C#, and understand programming. I'm looking for some specifics for Cocoa and in a larger sense getting into C++ in general. My primary goal is to be able to write extensions and functionality for a program we are getting at my work. It's in C++, so I need to get started. I figured while I'm doing it, I might as well delve into Cocoa as well.
Aug 27, 2007, 04:52 PM
Cocoa doesn't strictly work with C++. Cocoa works with Objective-C and Carbon works with C and C++ but there is no specific C++ support.
You can use C++ with Qt or a number of other C++ enabled frameworks, if you're really interested in getting deep into C++ (and multiple platform) programming.
Aug 28, 2007, 12:27 PM
I believe your biggest hurdle going from C# to C++ will be pointers and memory management. I'd suggest picking up a beginning C++ book and just quickly going through it but mostly focusing on pointers and memory. There are a lot of similarities between the two languages though. One thing you'll probably miss though are events, I love those in the .Net languages. There are no interfaces either but you can kind of accomplish this with pure virtual functions and multiple inheritance, thought you should be very careful about using multiple inheritance and I might even get flamed for even suggesting it :D
Aug 28, 2007, 12:41 PM
As a programmer who has done both C# and Cocoa(Obj-c) development, I can say that C# is a lot easier to use. Cocoa definitely has its ups- it's faster as it's compiled beforehand, but this comes at a price of memory management.
Additionally, Objective-C is a different kind of language. For example, in C#, you might call a quadratic solving function like this:
In Objective-C, you would probably call it like this:
[solveQuadratic withA:5 andB:2 andC:1];
As you can see, the syntax is totally different; arguments have labels and everything is enclosed in brackets. A lot of people consider the Objective-C approach to be more elegant as it includes labels and as the entire function call is in brackets, but it definitely requires some getting used to after knowing Java/C#.