actually u edited ur post after i posted my rply...that led to misunderstanding |
I edited the text, not the code.
by the way what is the need to use const keyword |
In C there is only one way to pass parameters to a function, pass by value.
http://en.wikipedia.org/wiki/Pass_by_value#Call_by_value
In C, you implement pass by reference by passing the address of the variable yourself and dereferencing it in the function yourself. You can do this in C++ too.
C++ introduced pass by reference, which allows does the same as passing the address of the variable without you having to deal with all the clunky syntax. Plus, you know that a reference is
always bound to a variable, whereas a pointer may or may not be bound to something.
Passing by const reference is better than passing by value because you don't incur the cost of copying the object to the temporary copy of the object to the stack. And you also get a read-only thing, so you can't modify it. So it's the preferred way of passing read-only objects to functions.
do u know hw much time this java and game programming will take and hw difficult it is as compared to c/c++..?? |
C is a simple language with very few rules, supports the procedural paradigm and pushes most of the functionality into the standard library.
C++ is an incredibly complicated language. It supports the procedural and object oriented paradigm. And it comes with a really cool library, the standard template library.
Java is a much simpler language than C++. It only supports the object oriented paradigm, but has a more sophisticated object model than C++ which support more run-time discovery and aspect oriented programming. There are many more de-facto standard libraries and frameworks for Java.
If you don't know about pass by value ... you probably really don't know that much about C++. It's much easier to become an expert at Java. Much of its use is more self-evident.