BSCS, BSIT and BSSE students who need a free C++ text can read C++ Programming, the open Wikibook written by Wikibooks contributors, at its official source. It covers the course most Pakistani universities teach in the first two years, Programming Fundamentals and Object-Oriented Programming with C++. It starts with what a compiler does, then moves through variables, functions, classes, inheritance and polymorphism.
The book is organised into five chapters: a language overview, fundamentals, object-oriented programming, advanced features such as templates, the STL and exceptions, and topics beyond the standard such as design patterns and threading. It is a living wiki, so some pages are polished and others are stubs, and the book’s own banner warns that it describes the older C++11 standard. This page shows which parts to trust, which to skip, and what to pair it with for lab exams and interviews.
Book Overview
| Course | Programming Fundamentals and Object-Oriented Programming (C++) |
| Degree Programs | BSCS, BSIT, BSSE |
| Level | University, first and second year — no prior programming experience assumed |
| Edition | Living wiki with no fixed edition; the main page was last edited on 25 September 2026 |
| Author(s) | Wikibooks contributors (the book’s About page names Panic and Thenub314 and points to the page history for the rest) |
| Publisher | Wikibooks (Wikimedia Foundation) |
| C++ Standard | Mostly C++98/C++03 with C++11 notes; no C++17 or C++20 teaching content found |
| Structure | 5 chapters (about 80 linked pages) plus 4 appendices: reference tables, external references, examples and exercises |
| Exercises | Appendix D lists five exercise sets; uneven in quality |
| Language | English |
| License | Creative Commons Attribution-ShareAlike: version 4.0 according to the Wikibooks site footer; the book’s own About page names version 3.0 Unported |
| Format | Free HTML (read online, always current) with a printable single-page version; a community PDF from April 2012 (684 pages) also exists |
Chapter List
Chapter 1: C++, a Multi-Paradigm Language
Difficulty: Easy · Key topics: history, ISO standards, paradigms, static typing, encapsulation, inheritance, polymorphism, comparison with C and Java
The chapter defines C++ as a general-purpose, statically typed, multi-paradigm language that Bjarne Stroustrup began at Bell Labs in the 1980s as “C with Classes”. It lists the standards in order: C++98 (ISO/IEC 14882:1998), C++03, C++11 (approved in August 2011) and the C++14 specification. A short page on low-level versus high-level languages leads into the longest page, on paradigms: procedural, static typing, objects and classes, encapsulation, inheritance, polymorphism and generic programming. The comparison pages then set C++ against C, Java, C#, Managed C++ (C++/CLI) and D.
Key Points:
- C++ grew out of C and added classes, virtual functions, templates, namespaces, operator overloading and exceptions.
- Standards named in the chapter: C++98, C++03, C++11 and C++14.
- Statically typed means every variable must be declared with a type before use, and type errors are caught at compile time.
- Encapsulation hides the data of a class behind a public interface so that other code does not depend on the details.
- Overloaded functions are chosen at compile time (static polymorphism); virtual functions are chosen at run time (dynamic polymorphism).
- C++98 is very nearly, but not quite, a superset of C89: classes, overloading, templates and access control exist only in C++.
Practice Tip: Type the Hello World program from this chapter, compile it with g++ hello.cc -o hello and run it. Then change std::endl to a newline character and see what changes in the output.
Common Mistake: Treating C++ as “C with a few extras”. The C comparison page shows that valid C code can fail in C++ because of reserved words and stricter type checking.
Important Questions:
- Why is C++ called a multi-paradigm language? It supports procedural, object-oriented and generic programming (and some functional style) in the same language, and the programmer may mix them.
- What is the difference between static and dynamic polymorphism? Static polymorphism (function overloading) is resolved by the compiler; dynamic polymorphism (virtual functions) is resolved at run time from the object’s real type.
Chapter 2 (Part 1): The Code, Compiler, Preprocessor and Linker
Book Chapter 2 · Difficulty: Easy · Key topics: keywords, file organization, coding style, scope, namespaces, compiler, preprocessor, linker
This part covers everything around the code before any logic is written. It starts with what a program is and warns that the standard leaves some behaviour undefined, which becomes visible when one program is built with different compilers. It then gives the keyword list (the C++98 set plus C++11 additions such as nullptr and constexpr), header and source file naming, makefiles, statements, coding style and documentation, and global, local and namespace scope. The compiler, preprocessor and linker pages explain the build chain, including macros, conditional compilation and linkage between translation units.
Key Points:
- Every statement ends with a semicolon, and braces group statements into a compound statement.
- C++ standard headers have no
.hextension (for exampleiostream), and their names live in thestdnamespace. - Preprocessor directives start with
#:#include,#define,#if,#ifdef,#ifndef,#pragmaand#undef. - Building a program means preprocessing, compiling each source file to an object file, then linking the object files and libraries.
- The linker resolves symbols used in one translation unit but defined in another; such symbols have external linkage.
- A
namespaceblock creates a new scope that prevents name collisions.
Practice Tip: Split a small program into a header, an implementation file and main.cpp. Compile each with g++ -c and link them in a separate step, then delete one file to see an “undefined reference” linker error.
Common Mistake: Using #define macros for constants out of C habit. The book notes that const is the usual C++ choice, because macros ignore types and scope and make code harder to debug.
Important Questions:
- What does the linker do? It combines the object files and libraries, matching every use of a symbol with its definition, to produce the executable.
- What is a namespace used for? It groups names under one label so that identically named functions or classes from different libraries do not clash.
Chapter 2 (Part 2): Variables, Types, Operators and Type Casting
Book Chapter 2 · Difficulty: Medium · Key topics: bits and bytes, standard types, modifiers, declaration vs definition, operators, pointers, sizeof, new and delete, casts
The part begins with how data is stored (binary, bits and bytes) and how a variable’s scope sets its lifetime. The type page covers the standard types bool, int, char, float and double, the size and sign modifiers, declaration versus definition, enumerations and typedef. The operator page works through precedence, assignment, arithmetic, compound assignment, pre and post increment, bitwise operators, and the pointer operators with null pointers, sizeof and dynamic memory. Logical operators, the ?: operator and the C++ cast operators close the part.
Key Points:
- A declaration announces a name and type; a definition allocates storage. A name may be declared many times but defined only once.
- Portably,
intis only guaranteed 16 bits (-32767 to 32767), andsizeofreports sizes in multiples ofchar. x = 2; a = x++;leavesaas 2 andxas 3;++xwould increment first.- A pointer stores an address:
*declares and dereferences it,&takes an address, and the null pointer is the constant 0. newanddeletemanage dynamic memory, which lives until it is explicitly released.- Narrow integer types are promoted to
intin arithmetic;static_cast<T>(expr)is the basic explicit conversion.
Practice Tip: Print sizeof for char, short, int, long and double on your own machine and compare the numbers with the type table in the book.
Common Mistake: Forgetting that integer division truncates. The operators page itself shows that 2/3 is 0, so 2/3-1 is -1 and not 1.
Important Questions:
- What is the difference between a declaration and a definition? A declaration states the type and properties of a name; the definition is the one place that actually reserves storage.
- What is the difference between
++aanda++? Pre-increment adds one before the value is used in the statement; post-increment uses the old value and adds one afterwards.
Chapter 2 (Part 3): Flow of Control, Functions, the Standard C Library and Debugging
Book Chapter 2 · Difficulty: Medium · Key topics: if, switch, loops, break and goto, function parameters, default values, recursion, overloading, C library, debugging
Flow of control covers if, switch, while, do-while and for, with break, continue and a discouraged goto. The functions page is the biggest in the chapter: declarations, main, inline, passing by value, pointer and reference, const parameters, default values, return codes, recursion, function pointers with callbacks, and overloading. The Standard C Library pages catalogue the C functions that C++ keeps, grouped as I/O, strings, math, time and memory. The part ends with debugging: kinds of bugs, tracing, breakpoints, watchpoints and the call stack.
Key Points:
- In a
switch, execution falls through to the next case unless abreakends the case. - A
do-whileloop tests its condition at the end, so the body runs at least once. - Passing by reference (
void swap(int& x, int& y)) lets a function change the caller’s variables; passing by value works on copies. - For
int foo(int a, int b = 5, int c = 3), the callfoo(6, 1)is the same asfoo(6, 1, 3). mainreturns anint; 0 means success, and reaching the end ofmainreturns 0 automatically.callocallocates an array and sets every cell to zero, and any block frommalloc,callocorreallocis released withfree.
Practice Tip: Write swap three ways (by value, by pointer, by reference) and print the variables before and after each call to see which versions really swap.
Common Mistake: Forgetting break in a switch. The book’s own list of common errors names it, because the program silently runs into the next case.
Important Questions:
- What is the difference between call by value and call by reference? By value passes a copy, so the original is unchanged; by reference passes an alias to the original, so changes are visible to the caller.
- What is function overloading? Several functions share one name but differ in the number or types of parameters, and the compiler picks one by overload resolution.
Chapter 3 (Part 1): Structures, Unions and Classes
Book Chapter 3 · Difficulty: Medium · Key topics: struct, union, class, access labels, constructors, destructors, initialization lists, inheritance, this pointer
The object-oriented chapter starts with the structure, which the book presents as a simple form of the object idea: a struct is like a class except that its members are public by default. Unions follow, where all members share one memory location. The Classes page is the core of the book: declaration, public, private and protected, data and static members, constructors with initialization lists, destructors, const and static member functions, accessors, and patterns such as container, interface and singleton classes. Inheritance, member functions and the this pointer have their own pages.
Key Points:
- The only default difference: members of a
structare public, members of aclassare private. - All members of a
unionshare the same memory, its size is that of the largest member, and it cannot have a destructor. - A constructor has the class name and no return type; an initialization list is the only way to initialize members and base classes that need a non-default constructor.
- A destructor is written
~ClassName(), takes no arguments, cannot be overloaded, and releases resources when the object is destroyed. - Class members can be defined outside the class body with the scope resolution operator
::. thisis available only inside non-static member functions; multiple inheritance lets a class derive from several bases.
Practice Tip: Write a small Account class with a constructor that uses an initialization list and a destructor that prints a message. Create objects in nested blocks to see the order in which they are built and destroyed.
Common Mistake: Expecting class members to be public. The book states that all class members are private by default, so code outside the class fails to compile until an access label is added.
Important Questions:
- What is the difference between a struct and a class in C++? Both can have members, functions and inheritance; the default access is public for a struct and private for a class.
- Why use a constructor initialization list? It initializes members before the constructor body runs, it is more efficient, and it is required for members or bases without a default constructor.
Chapter 3 (Part 2): Polymorphism, Abstract Classes, the “Nice” Class and Operator Overloading
Book Chapter 3 · Difficulty: Hard · Key topics: virtual functions, dynamic binding, pure virtual functions, abstract classes, copy constructor, law of three, operator overloading
This part explains how a derived class overrides a base-class function. A stack object uses static binding, but a pointer or reference to the base class needs the virtual keyword so the right version is chosen at run time. The book then covers pure virtual functions (= 0), abstract classes, pure abstract classes used as interfaces, covariant return types and virtual destructors. The “nice” class page lists what a container-safe class needs: copy constructor, assignment operator, equality and inequality operators. The last page covers operator overloading syntax and the operators that cannot be overloaded.
Key Points:
- An object on the stack uses static binding; only a pointer or reference to a base class, together with
virtual, gives dynamic binding. - A pure virtual function ends with
= 0; a class containing one is abstract and cannot be instantiated. - A pure abstract class has only pure virtual functions and works as an interface that derived classes must implement.
- The law of three: if a class needs a user-written copy constructor, copy assignment operator or destructor, it usually needs all three.
- Operators are overloaded with
return_type operator@(parameters); new operators cannot be invented and precedence cannot change. - These cannot be overloaded:
?:,.,.*,::,sizeof,typeidand the named casts.
Practice Tip: Build a Shape base class with a pure virtual area() and derive Circle and Rectangle. Call area() through base-class pointers, then remove virtual and watch the wrong version run.
Common Mistake: Leaving the base-class destructor non-virtual. The book stresses that every polymorphic base needs a virtual destructor, even an empty one, or deleting through a base pointer skips the derived destructor.
Important Questions:
- What is a virtual function? A member function that a derived class can override, called through a base pointer or reference so that the object’s real type decides which version runs.
- Which operators cannot be overloaded? The conditional
?:, member selection.and.*, scope resolution::,sizeof,typeidand the four named cast operators.
Chapter 3 (Part 3): Standard Input and Output Streams and the string Class
Book Chapter 3 · Difficulty: Easy · Key topics: streams, cin and cout, file streams, open modes, string class, getline, conversion
The I/O page starts from the idea of a stream, one model for console, file, network and string input and output, and notes the ASCII character set. It then covers iostream (cin, cout, cerr, clog), file streams in fstream with their open modes, and formatting with manipulators such as setw. It shows how to define operator<< so your own class can be printed. The string page replaces unsafe C character arrays with std::string: reading text, size, operators, searching, inserting and erasing, concatenation, and converting to and from numbers.
Key Points:
cinis anistreamandcoutis anostream; both are defined in<iostream>and chained with>>and<<.ofstreamandifstreamcome from<fstream>;ios::appappends,ios::outoverwrites andios::inreads.- To print your own class with
cout, defineostream& operator<<(ostream&, const T&)and return the stream. std::stringneeds<string>and grows automatically, replacing fixed C character arrays.- The string page covers
getline,find,c_str,stoi,to_stringandstringstream.
Practice Tip: Write a program that asks for a name and age, writes them to a text file with ofstream, then reads the file back with ifstream and prints it.
Common Mistake: Expecting cin >> text to read a whole line. It stops at the first space, which is why the string page shows getline.
Important Questions:
- How do you open a file so that new data is added at the end? Open it with the
ios::appmode, for examplefile.open("a.txt", ios::app). - Why prefer
std::stringto a char array? It manages its own memory, resizes automatically and offers safe operations such as concatenation and searching, avoiding buffer overflows.
Chapter 4 (Part 1): Templates, Template Meta-Programming and the STL
Book Chapter 4 · Difficulty: Hard · Key topics: function templates, class templates, specialization, compile-time programming, containers, iterators, functors, algorithms
Templates let one function or class work for many types. The page shows function and class templates, how templates compare with macros, type-safe instantiation at compile time, and the linkage problem when template code is split across files. The template meta-programming page treats templates as compile-time computation (Turing complete, using recursion and branching on types) and carries a notice that it may need updating. The STL page introduces containers, iterators, functors and algorithms. Two items listed in the chapter contents, Type Traits and Concepts, are links to pages that do not exist yet.
Key Points:
- A function template looks like
template <typename T> T max(T x, T y)and is instantiated by the compiler for each type used. - Templates are type safe, allow user-defined specialization and non-type parameters, and, like macros, add no run-time overhead.
- Sequence containers:
vector,listanddeque; associative containers:map,multimap,setandmultiset; adapters:stack,queueandpriority_queue. - An iterator is a generalized pointer, so the same algorithm (for example
std::sort) works on arrays and on containers. - A functor is an object with
operator()that can keep state, such asstd::less.
Practice Tip: Write your own Stack<T> class template, then count how often each character appears in a line of text using std::map<char, long>.
Common Mistake: Putting template member definitions in a .cpp file. The book’s linkage section explains that this produces “unresolved reference” errors, because the compiler cannot instantiate code it cannot see.
Important Questions:
- What is a template in C++? A pattern for a function or class with the type left as a parameter, so the compiler generates a type-safe version for each type you use.
- What are the main parts of the STL? Containers that hold data, iterators that walk over them, functors that customize behaviour, and algorithms such as sort and copy that work through iterators.
Chapter 4 (Part 2): Smart Pointers, Exception Handling and RTTI
Book Chapter 4 · Difficulty: Hard · Partly dated · Key topics: auto_ptr, ownership, throw, try, catch, stack unwinding, exception safety, noexcept, dynamic_cast, typeid
The smart pointer page argues that raw pointers cleaned up in destructors are error-prone and demonstrates auto_ptr, whose copy hands ownership to the target and leaves the source empty. Its banner says auto_ptr has been deprecated since C++11 in favour of unique_ptr, shared_ptr and weak_ptr. The exception page covers throw, try and catch, stack unwinding, exception class hierarchies, levels of exception safety and exception specifications. The RTTI page covers dynamic_cast, typeid, their limits and misuse.
Key Points:
- An
auto_ptrhas strict ownership: aftery = x;the sourcexholds a null pointer. Useunique_ptrin current code. - When an exception is thrown, stack unwinding destroys the local objects of every function it leaves before a matching
catchruns. - Throw objects, ideally from a class hierarchy, rather than pointers or primitive values.
- The strongest exception-safety level is the no-throw guarantee: the operation always succeeds.
dynamic_caston a pointer returns a null pointer when the object is not of the requested type.
Practice Tip: Throw an exception from inside a function that has a local object with a noisy destructor, and watch the destructor run during stack unwinding before your catch block prints.
Common Mistake: Believing C++ has a finally keyword. The Exception Handling page has a section describing one, but the book’s own language-comparison page explains that C++ has no finally and uses RAII (destructors) instead. Trust the comparison page.
Important Questions:
- What is stack unwinding? The process of leaving functions one by one after a throw, destroying their local objects, until a handler for the exception is found.
- What does
dynamic_castreturn if the cast fails? For a pointer it returns a null pointer, so you can test the result before using it.
Chapter 5 (Part 1): RAII, Garbage Collection and Design Patterns
Book Chapter 5 · Difficulty: Hard · Key topics: RAII, resource wrappers, garbage collection, creational, structural and behavioral patterns, MVC
The chapter called “Beyond the Standard” opens with RAII (Resource Acquisition Is Initialization): acquire a resource in a constructor and release it in the destructor so cleanup happens even when exceptions occur. The page builds a small file wrapper around the C file functions that throws on open failure. The garbage-collection page explains why C++ leaves collection optional, citing run-time overhead, pauses and poor cache locality. The long Design Patterns page then works through the Gang of Four ideas with C++ code: creational (Builder, Factory, Abstract Factory, Prototype, Singleton), structural (Adapter to Proxy) and behavioral (Chain of Responsibility to Visitor).
Key Points:
- RAII ties a resource’s lifetime to an object’s lifetime, so a destructor guarantees cleanup without
try/catch/finallyblocks. - Standard file streams are an everyday example of RAII: they open in the constructor and close in the destructor.
- Garbage collection is optional in C++, and tracing collectors add overhead that hurts real-time and embedded programs.
- A design pattern is a named, repeatable approach to a common design problem, neither an algorithm nor ready-made code.
- The page covers five creational, nine structural (including Curiously Recurring Template and Interface-based Programming) and eleven behavioral topics, plus MVC.
Practice Tip: Write a small RAII class that prints “opened” in its constructor and “closed” in its destructor, then throw an exception while it is alive to prove the destructor still runs.
Common Mistake: Treating a pattern as code to paste. The book says a pattern describes a way to solve a type of problem, so the class names and details must be adapted to your design.
Important Questions:
- What is RAII? A technique where a resource such as memory, a file or a lock is acquired in an object’s constructor and released in its destructor, making cleanup automatic and exception safe.
- What are the three categories of design patterns? Creational patterns (how objects are made), structural patterns (how classes are composed) and behavioral patterns (how objects communicate).
Chapter 5 (Part 2): Libraries, Boost and Optimization
Book Chapter 5 · Difficulty: Hard · Key topics: libraries, API vs framework, static and dynamic linking, Boost, profiling, optimization
The libraries pages explain what a library and an API are, how a framework differs from a plain API, and the trade-offs of static against dynamic libraries, including binary and source compatibility and an example of configuring Microsoft Visual C++ include and library directories. The Boost page introduces the peer-reviewed, open-source libraries, with short sections on noncopyable, uBLAS linear algebra, Boost.Random and Boost.Thread. The optimization page insists on profiling first, then reviews simple code, the right container, lazy initialization, compiler optimizations, memory footprint, parallelization and I/O.
Key Points:
- An API is the set of functions, types and structures through which a program talks to a library or operating system; a framework also dictates how your code is structured.
- Static linking gives fewer files and no version checks but larger binaries, and bug fixes need a recompile.
- A library is binary compatible if a program keeps working with a newer version without recompiling.
- Most Boost libraries use the Boost Software License, which allows open and closed source use.
- The book’s rule: without profiling, an optimization claim is not worth trusting.
- Lazy initialization defers creating an object until it is needed.
Practice Tip: Take any loop-heavy program you have written, time it with a clock or profiler first, change one thing (for example the container type), and time it again.
Common Mistake: Optimizing by guesswork. The optimization page repeats that parallelism and clever tricks can even slow a program down when synchronization is required.
Important Questions:
- What is the difference between a static and a dynamic library? A static library is copied into the executable at link time; a dynamic library stays a separate file that is loaded at run time and shared between programs.
- What is the difference between an API and a framework? An API is only the interface of functions you call; a framework also defines how your code is organized and often calls your code.
Chapter 5 (Part 3): Platform and Systems Topics
Book Chapter 5 · Difficulty: Hard · Several pages are stubs · Key topics: cross-platform development, Win32, wrappers, multitasking, threads, internationalization, text encoding, UML
This closing set of pages is uneven. The Cross-Platform page is a short introduction of a few lines. The Win32 page describes the Windows API, DLLs and function groups for time, file system, network and resources, and the wrapper pages cover MFC and cross-platform toolkits such as Gtkmm and Qt. The Multitasking page is substantial: processes, context switches, scheduling types, inter-process communication, threads, race conditions, synchronization, fibers and OpenMP. Internationalization and text encoding (ASCII, Unicode, UTF-8, UTF-16, UTF-32) are short, and the UML page gives history and tools without diagrams.
Key Points:
- The Win32 API is the core C-based Windows interface; wrappers such as MFC hide its low-level detail.
- A context switch reassigns the CPU from one task to another, creating the illusion of parallelism on a single processor.
- A race condition occurs when threads access shared data concurrently and at least one access is a write.
- Fibers are lightweight threads that use cooperative scheduling, yielding voluntarily.
- Internationalization designs software to be adaptable; localization adapts it to a particular region and language.
- The threading page does not use the C++11 thread library:
std::threaddoes not appear in it.
Practice Tip: Read the race condition section, then write a small multi-threaded counter with your compiler’s thread library and see the wrong totals that appear without a lock.
Common Mistake: Expecting this part to be exam syllabus. These pages are background reading; the thin ones give a map, not a working method.
Important Questions:
- What is a race condition? A bug where the result depends on the timing of threads that share data without proper synchronization.
- What is the difference between internationalization and localization? Internationalization prepares code so it can support many languages and regions; localization supplies the translated text and local settings for one of them.
Appendices A to D: Reference Tables, External References, Examples and Exercises
Appendix · Difficulty: Easy · Key topics: keyword and operator tables, standard headers, further reading, example programs, exercises
Appendix A collects lookup tables used throughout the book: keywords, preprocessor directives, standard headers, data types, an operator table, the Standard C Library functions and an ASCII chart. Appendix B lists web links (reference sites, compilers and IDEs, libraries, coding conventions) and recommended books such as Bruce Eckel’s Thinking in C++ and Scott Meyers’s Effective C++. Appendix C, C++ Programming by Examples, explains Hello World line by line with compiler troubleshooting and lists compilable examples; the page is marked under construction. Appendix D has five exercise sets that are very uneven in quality.
Key Points:
- The data types table gives minimum sizes only: for example
charis at least 8 bits andintat least 16 bits. - The headers table separates the STL headers from the Standard C Library headers (the
c-prefixed ones such ascstdio). - The Examples appendix shows
g++ hello.cc -o helloand explains the common errorundefined reference to std::basic_ostream. - The Exercises appendix lists sets on variables and types, iterations, static arrays, functions and standard I/O.
- The Exercises and Examples appendices are marked as under construction and may contain errors.
Practice Tip: Use Appendix C as a lab warm-up: compile every Hello World variation, then do the iteration exercises with a pen-and-paper trace before running them.
Common Mistake: Relying on the external links without checking them. Some addresses are old (for example the SGI STL guide and an AT&T Research address for Stroustrup’s page), so expect to search for the current location.
Important Questions:
- What does the error “undefined reference to std::basic_ostream” usually mean? The program was linked as C instead of C++, for example with
gccinstead ofg++; compile withg++or add-lstdc++. - Are the data type sizes in the table fixed? No. They are minimum sizes; the real size depends on the compiler and platform, and
sizeofreports it.
How to Study This Book
The book’s own Preface gives the plan. If this is your first contact with programming, read from the beginning; if you already know another language, you may skim the Fundamentals chapter, but do not skip the Programming Paradigms page in Chapter 1. The preface warns that this page can be hard to digest without experience, so read it once for the vocabulary and come back after Chapter 3, when the ideas have code attached.
The blocks above follow the book’s own five chapters. Chapters 2 to 5 are too large for one block each (Chapter 2 alone has roughly thirty linked pages), so each is split into parts by the book’s own page groups: Chapter 2 into three parts, Chapter 3 into three, Chapter 4 into two and Chapter 5 into three. The Part numbers are this page’s labels, not the book’s. The appendices have a single block.
For a Programming Fundamentals course, work through Chapter 1 lightly, then Chapter 2 Parts 1 to 3 in order. Read the Standard C Library pages as reference only: they teach printf and C strings, and the book itself calls C-style I/O somewhat outdated. Use cin, cout and std::string from Chapter 3 Part 3 instead, and read that part early, right after Chapter 2 Part 2.
For an Object-Oriented Programming course, Chapter 3 is the syllabus. Read Parts 1, 2 and 3 in order: structures and classes first, then inheritance and member functions, then polymorphism and abstract classes, then the “nice” class and operator overloading. The Classes page is very long, so read it in several sittings and type the examples. Chapter 4 Part 1 (templates and the STL) is the second-year follow-up that data structures courses depend on.
Be selective with Chapter 4 Part 2 and Chapter 5. Learn the idea of smart pointers, but use unique_ptr instead of the auto_ptr in the examples, and ignore the section that describes a finally keyword. RAII is short and essential. Design patterns suit a Software Engineering course. Treat Chapter 5 Part 3 (Win32, UML, internationalization) as background, and use the Multitasking page only as an introduction before an Operating Systems course.
Know what is missing. The book teaches mostly C++98 and C++03 with C++11 notes, and its own banner calls its description of the standard old. In the text we read there was no teaching of C++17 or C++20 features, the pages for Type Traits and Concepts do not exist, and lambdas and move semantics get only passing mentions. After finishing Chapter 3, add a current reference for modern C++, and use your course lab manual for practice, because the exercise pages are thin and no solutions appendix was found.
Used In These Programs
This book is used for the Programming Fundamentals and Object-Oriented Programming (C++) courses in: BS Computer Science · BS Information Technology · BS Software Engineering. Browse all C++ books, all Object-Oriented Programming books or all Computer Science books.
Who Should Read This
This book suits first- and second-semester BSCS, BSIT and BSSE students who need a free C++ text for Programming Fundamentals or Object-Oriented Programming, and anyone moving to C++ from C or Java, because Chapter 1 compares the languages directly. It is not a good single source for exams that expect modern C++ (C++17 and later), and it is not a gentle, polished textbook: some pages are stubs, and a few contradict each other. Pair it with Object Oriented Programming Using C++ for a university-style course order, and move on to Data Structures in C++ once templates and the STL feel comfortable.
Applicable Universities
This book is useful for students at Pakistani universities offering BSCS, BSIT and BSSE including Punjab University, Virtual University, COMSATS, FAST, UET, NUST, and other HEC-recognized institutions.
Official Copy of C++ Programming
Click below to open the official C++ Programming Wikibook on Wikibooks. It is always the current text, so it is the version to read. Wikibooks also provides a printable single-page version and a community-made PDF on Wikimedia Commons, but that PDF is a 684-page snapshot from April 2012 and misses every edit made since.
→ Visit Official PageFAQs
Is C++ Programming (Wikibooks) free?
Yes. The text is published on Wikibooks under the Creative Commons Attribution-ShareAlike licence. The Wikibooks site footer links to version 4.0, while the book’s own About page names version 3.0 Unported. Either way you may read, share and adapt it with credit and under the same licence. The About page adds that code and media on some pages can carry their own licences.
Which edition is this, and is there a PDF?
There is no fixed edition. The book is a wiki, and its main page was last edited on 25 September 2026. A community PDF exists on Wikimedia Commons, but it has 684 pages and dates from April 2012, so it misses every later change. Use the online version as the current text.
How many chapters and exercises does it have?
Five chapters with about 80 linked pages, plus four appendices: reference tables, external references, examples and exercises. The exercises appendix lists five sets (variables and types, iterations, static arrays, functions and standard I/O). They are uneven in quality, and we did not find a solutions appendix.
Is it good for complete beginners?
It can be used that way, because the preface says to read from the beginning if programming is new to you. But it is a community wiki: style and depth vary, some pages are stubs, and there is no step-by-step lab path. Beginners should do the practice questions from their course lab manual or a companion book alongside it.
Does it cover OOP, templates and the STL?
Yes. Chapter 3 covers classes, inheritance, virtual functions, abstract classes and operator overloading, and Chapter 4 covers templates, the STL, exceptions and RTTI. The pages for type traits and concepts are listed in the contents but do not exist yet.
Is it still current in 2026?
Only partly. The core language material is still correct, but the book’s own banner says it describes the older C++11 standard, it teaches auto_ptr (deprecated since C++11), and we found no C++17 or C++20 content. Use it for the fundamentals and OOP, and add a modern C++ reference for newer features.
Related Books
- Object Oriented Programming Using C++ – IT Series
- Key Book to OOP C++ Programming Exercises – IT Series
- Data Structures in C++ – Aikman Series
- Programming Fundamentals – Kenneth Leroy Busbee
C++ Programming on Wikibooks is a free, open way to cover the fundamentals and object-oriented parts of a university C++ course, from your first compiled program to classes, polymorphism and the STL. Treat it as a community text: trust the core chapters, check the dated pages against a current reference, and keep your course lab manual for exercises. Browse more Computer Science books for the rest of your semester.
C++ Programming, by Wikibooks contributors (the book’s About page names Panic and Thenub314 as authors). Published on Wikibooks, a Wikimedia Foundation project, continuously updated. Free under the Creative Commons Attribution-ShareAlike licence: version 4.0 according to the Wikibooks site footer, version 3.0 Unported according to the book’s own About page. Official source: https://en.wikibooks.org/wiki/C%2B%2B_Programming
© Copyright Policy
Freebooks.pk is an educational resource for students in Pakistan. Textbooks and other books belong to their respective boards, authors and publishers, and all rights remain with them. If you are the copyright holder of any material on this page and want it changed or removed, please contact us or file a request under our DMCA policy. We review every request and remove reported content promptly.
