Question

At my university most of my classes have been in Java. I have also recently learned C# (and the Visual Studio environment) at a summer internship. Now I'm taking an Intro to Computer Graphics class and the grad student teaching the class prefers us to use C++ to access the OpenGL bindings via GLUT.

Does anyone have any good resources on how to make a good transition from Java/C# to C++? Obviously pointers are going to be a big issue, but any other things I should be looking out for? Any tutorials, guides, etc. would be very helpful!

Thanks!

Was it helpful?

Solution

Yeah, I got bit by the same bug. The university tended to lean on Java, and then allowed you to choose the language you wanted to work with during projects.

The best way is to just jump in. Start small, take baby steps, and just Google things that confuse you when you get there. Also find projects that have released their source code. See how they structure their programs. Basically, just tinker with concepts. There is plenty of information around the web.

Make it fun and grab a C++ game development book so it doesn't become mind numbing too quickly.

Here's some places that I found useful while learning

http://www.cprogramming.com/

http://www.wikipedia.com

http://www.cplusplus.com/

OTHER TIPS

If you already know Java/C# I'd recommend going directly to C instead of C++. According to the website, GLUT has the same bindings for C as C++ so you should be all set. Anyways, the best way to learn C is to purchase and read a copy of "The C Programming Language" and sit down with your C compiler and get your stuff to run.

Effective C++ by Scott Meyers is a great book to help you learn C++. Gives you an overview of the language and introduces a lot of key concepts that you will use throughout the development of basically any C++ program.

Effective C++ by Scott Meyers is a great book to help you learn C++. Gives you an overview of the language and introduces a lot of key concepts that you will use throughout the development of basically any C++ program.

I love this book in all 3 editions, and it was one of the books in a class I had as a Senior at UT, but it's just not a starting book. You can become comfortable in C++ with a lot less, though you certainly won't be one with the compiler until you have read Meyer's work.

I don't know if it's still in print but I found Navigating C++ usefull, but I was also very comfortable with pointers from Pascal. Err of course I am forgetting that 15 years ago you had to learn what OOP was, now it's a little more assumed. So perhaps Meyer's is not out of line. Thoughts?

Wikipedia has an article on comparisons between Java and C++.

You don't have to worry about checked exceptions in C++, but you do need to know about const correctness.

There are two main differences: the syntax, and memory management.

In C++ you have pointers, which are more powerful (or less powerful depending on your interpretation of power) object references, which you already know about from Java.

In Java you might do this:

Thing mything = new Thing(); // mything is an object reference
mything.method();

In C++ you would do this:

Thing * mything = new Thing(); // mything is an object pointer
mything->method();
delete mything;

The syntactical difference is obvious: '->' instead of '.' when calling an object method from a pointer to an object. In C++, you have to free the memory explicitly when you are done with an object. At the end of the day you are doing the same thing in C++ and Java, instantiating objects and calling methods, putting useless semicolons at the end of every line, etc. Is it any wonder that Python is becoming so popular?:

mything = Thing() # mything is whatever I want it to be
mything.method()

Skimming through any half decent C++ text will help you fill in the rest of the details.

I also thoroughly recommend Bruce Eckel's Thinking in C++. A fantastic book for already experienced programmers that want to get into the C++ mindset.

He is kind enough to make electronic versions of his books available for free.

I strongly recommend that anyone learning C++ reads Stroustrups "The C++ Programming Language." Meyers and Eckel have great stuff, but nothing beats learning from the guy who decided what the language should be and how he intended for it to be used.

I had the exact same issue. The only book I was able to find was "Pro Visual C++ 2005 for C# Developers" by Dean C. Wills. It's a good read with excellent examples, and I think the angle from which the book comes is probably what you're looking for.

You will need a completely differnt feeling for memory handling. Also think about freeing everything you don't need anymore. In Java and C# you just let go of your objects and the memory gets tidy up for you - you can't do that in CPP

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top