I am a new programmer in the c++ arena..can you suggest me good beginer books for this language.
& also can u suggest me whether it is possible to
do multi threaded programming using c++.
And one more specific question ..What is called reference type..
I would remain ever greatful to u for ur kind healp.
C++ Books and C++ Information Resources:
There are many books on C++ but not many good ones for beginners.
For absolute beginners there is a book called
"You Can Do It - A Beginner's Introduction to Computer Programming" by Francis Glassborow and Roberta Allen.
If you already have some programming experience people often recommend
"Accelerated C++" by Koenig and Moo
although I myself have not read either of them.
For general good C++ usage you should look at:
"Effective C++" "More Effective C++" and "Effective STL" by Scott Meyers
and the more advanced:
"Exceptional C++" and "More Exceptional C++" by Herb Sutter (See also http://www.gotw.ca/gotw/index.htm
"Modern C++ Design" by Andrei Alexandrescu
"Ruminations on C++" by Koenig and Moo
(Herb Sutter also has a couple of new books out that I have not yet had the time to read: "Exceptional C++ Style" and "C++ Coding Standards" in conjunction with Andrei Alexandrescu).
For C++ reference you should look at:
"The C++ Programming Language" 3rd Ed. by Bjarne Stroustrup
the C++ reference book from the man himself. In addition you will most likely find that a couple of additional reference works will be of use. For the standard C++ library there is:
"The C++ Standard Library - a tutorial and reference" by Nicolai M. Josuttis - one of my most referred to books.
and for C++ templates there is:
"C++ Templates the Complete Guide" by David Vandevoorde and Nicolai M. Josuttis
The final reference work I am going to recommend is the C++ standard document itself which is published in book form by Wiley or is available for download as a PDF from the ANSI web site for $18 (price the last time I checked):
"INTERNATIONAL STANDARD ISO/IEC 14882 Programming Languages C++"
the book is just titled:
"The C++ Standard"
You might also like to consider obtaining a copy of the C language standard as well.
There are many books on programming in general that are good. I found:
"The Practice of Programming" by Kernighan and Pike
to be particularly useful.
Finally, other C++ resources include:
A C++ FAQ at: http://www.parashift.com/c++-faq-lite
and lots of book reviews and resource links at:
If you join the ACCU then they have mentored developer projects you can participate in including a "Begin C++" project.
Multi Threaded Programming Using C++
There is no standard support for multithreaded programming in C++ (or C for that matter) but you can do it using raw operating system API features or a some 3rd party library that wraps these features for you. Two cross platform / compiler libraries with multithread support features are the ACE library (see http://www.cs.wustl.edu/~schmidt/ACE.html
) and the Boost thread library (see http://www.boost.org/
for the Boost home page and http://www.boost.org/doc/html/threads.html
for information on the thread library).
There is work going on for the next C++ language standard an some of the proposed changes include a better presumed machine model (presumed by the compiler) to support multithreaded applications.
The word reference is confusing when talking about C++. This is because it has a general meaning for programming and a specific C++ meaning.
From the general point of view C++ supports two reference types: pointers and references.
From the C++ point of view there are C++ references.
From the Java and .NET / C# perspective the reference types used there probably behave more like C++ pointers that C++ references.
In C and C++ a pointer type is a type that points to an object rather than referring to the object itself. You have to de-reference a pointer to refer to the thing to which it points; you have to take the address of an object to get its pointer. You declare a pointer type by using * with the name of the type to which the pointer points:
MyType o; // Value type of type MyType
MyType * p; // Un-initialised pointer to objects of MyType
p = NULL; // p is assigned a NULL pointer value (C style)
p = 0; // p is assigned a NULL pointer value (C++ style)
p = &o; // p is assigned the value of the address of o
MyType o2 = *p; // New MyType initialised from other MyType.
// To obtain this we have to de-reference the
// pointer to o to use o.
MyType o3(*p); // Same as previous line but using preferred
// C++ initialisation syntax.
In C++ (but not C) there are also reference types. These are similar to pointers except that:
- you declare a reference to some type using the & character with the type name instead of the * character.
- you *must* initialise a reference to refer to some object – unlike a pointer it cannot be un-initialised or refer be a null reference.
- you do not need to de-reference them to refer to the object they refer to.
int i(210); // Some integer value
int & ri(i); // Some reference to i, ri must be initialised
int j(ri); // j is a new int object; j = 210
ri = 10; // ri refers to i so i has the value 10
int k(i); // k is another int object; k = 10.
int * pi(&ri); // pointer to int, initialised from reference.
// Notice the syntax is the same as if we
// initialised pi from i – we take the address
// of the reference to obtain a pointer.
int * ri2(*pi); // Conversely we dereference a pointer to
// obtain a reference.
One of the common uses for pointers and references is pass them into and out of functions as parameters. In both cases the effect is that no copying of the original object is performed – only a pointer or reference is copied. So both effectively can be used to pass parameters by reference rather than by value.
The above is necessarily brief so do not expect it all to sink in for a while. Get hold of some of the book I mentioned and read up on C++ - you will find more advise in some of them on these issues.