Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

Search: 

  Tutorial: C and Cpp Programming in C and Cpp Introduction to the C++ Standard Template Library Tutorial

This tutorials introduces you to the C++ Standard Template Library (STL) including how to use I/O streams, file streams, string streams, strings, vectors, lists, maps, iterators, and algorithms.

Tutorial Details:

The C++ Standard Template Library

The C++ language is not a simple language. In fact, many would argue it is a somewhat overcomplicated language. Nevertheless it can be used to write beautiful code. On top of that it is so widespread that example code and libraries (free ones, too) are all over the Internet.

To be able to write working programs in C++, you'll need a decent grasp of the subtleties of the language itself. That is not what this article is about. On top of understanding the language, it helps tremendously to be able to use the standard library correctly. That is what this article is about. You'd be surprised how many people program in C++ but ignore most of its features. That is not necessarily a bad way to program, but you can save yourself a lot of work by using all of the language.

A reason many people avoid the standard library are that they are worried about performance. Especially game developers often suffer from a syndrome where they do not trust any code that they can not mentally compile to assembly instructions on the spot. The conveniences of the standard library and all those templates, they think, just can't be fast. In fact, the whole standard library was designed with performance in mind, and often things will compile to code that is just as efficient as a solution you write yourself. Another very common (and somewhat related) reason not to use standard library functionality is that people refuse to use anything they did not program themselves in their programs. While it is very educational to make everything yourself at least once, if you want to be productive you'll have to start using other people's code, it is available and it is well tested.

The most important parts of the C++ standard library are its containers, iterators, the iostream classes and the algorithms. All classes and functions in the standard library are inside the namespace 'std'.

When passing non-trivial objects to functions or returning them you should get in the habit of passing by reference. This is basic C++ stuff but you really must know this to use standard containers. Do take care not to return references to local objects that will vanish when their scope exits. Also, when you do not intend to modify an object, pass it by const reference, that way temporary objects can be passed, the compiler will complain if you try to pass a temporary object by non-const reference.

All examples in this article use code without indicating any function it is in, and to make things worse I write #include at the same level too. I do this mostly to avoid unneccesary clutter and keep the code readable. This is not valid C++ though, if you want to actually compile it add an 'int main(){ ... }' function around the code (not the includes).


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
C and Cpp Programming in C and Cpp Introduction to the C++ Standard Template Library Tutorial

View Tutorial:
C and Cpp Programming in C and Cpp Introduction to the C++ Standard Template Library Tutorial

Related Tutorials:

Displaying 1 - 50 of about 3706 Related Tutorials.

C/C++ Programming Books
C/C++ Programming Books C/C++ Programming... topics for Visual C++ 6 programming. This book skips the beginning level material... follow: The compiler offers improved support for the ANSI C++ standard
 
C and C++ books-page3
at the standard C programming language. In no way does this guide attempt to teach... library. This guide is not a definitive look at the entire ANSI C standard. Some... of the functions available in the standard C library. These parts were designed to insure
 
Objective C Introduction
Objective C Introduction Objective C... Objective C programming language. Objective C is very old programming language...; Objective C is simple and very intuitive programming language that makes the Object
 
C and C++ books-page4
;     The UNIX System call in c programming In order...; The C tutorial-Brackets and Braces Some of the characters C uses...; Introduction to C Programming  C has been used successfully
 
Objective C Tutorial
Objective C Tutorial,Objective C Tutorials Objective C Tutorial        ...;      In this Objective C Tutorial we
 
Objective C
Objective C, Objective C programming language, Objective C Language... Objective C Tutorial About the Objective C tutorial presented here. In this complete guide of Objective C you will be learning the programming concepts
 
C and C++ books
API programming in C. Each tutorial contains C ODBC code samples...; Page 10 As a programming language, C is rather like Pascal... in Stockholm, Sweden. A programming standard for the project was written by Erik
 
C and C++ books-page8
tutorials that introduce you to ODBC API programming in C. Each tutorial... how to write software in C. It is written primarily as a tutorial for beginners... C and C++ books-page8 C and C++ books-page8
 
For C++ programmers
in C++'s Standard Template Library (STL). Java 5 introduced generics, which.... The Java libraries are astounding more extensive than the standard C++ libraries... Java: For C++ programmers
 
C and C++ books
API programming in C. Each tutorial contains C ODBC code samples...; Page 10 As a programming language, C is rather like Pascal... in Stockholm, Sweden. A programming standard for the project was written by Erik
 
C and C++ books-page11
-based programming, generic programming, and functional programming. C...; Operator overloading of C++ Programm Object-oriented (OO) programming... C and C++ books-page11 C and C++ books-page11
 
Ask C/C++ Questions online
;    C and C++ are different programming... purpose programming language that can run on most of the platforms. C is used... Bell Laboratory while C++ is a popular object oriented programming language
 
C and C++ books-page2
;       The C Programming Language ... C and C++ books-page2 C and C++ books-page2...; The Advice & Warning for C Tutorials  C and C
 
C and C++ books-page1
of this tutorial is to give a good understanding of the programming language C..., loops and arrays, object-oriented programming, templates, and creating C... and the concepts involved with programming C++. You'll find the numerous examples
 
Cantata++ - for testing C and C++ software
Cantata++ - for testing C and C++ software Cantata++ - for testing C and C++ software    ... the requirements of the C/C++ languages to produce a tool which allows developers
 
Java vs. C
object-oriented programming (OOP). It's possible to write in Java in a C... for Object Oriented Programming (OOP). Java classes are like C++ class, which... Java: Java vs. C Java
 
EasyEclipse for C and C++
Eclipse Plugin-Language EasyEclipse for C and C...;   EasyEclipse for C and C++ is all you need to start developing C and C++ code with Eclipse. There are currently 28 comments
 
C# Programming Books
C# Programming Books C# Programming Books... With Microsoft's introduction of the .NET platform, a new, exciting programming language... Started C# is pronounced as "C sharp". It is a new programming language
 
Objective C on Windows
. GNUset is objective c compiler for windows, that we will be using in our tutorial... Objective C on Windows, Objective C  Windows, Objective C Windows Compiler, Objective C Compiler for Windows Objective C
 
Why Objective C?
; In this section we will learn about the importance of Objective C and "Why Objective C?" is used as programming language to develop... Why Objective C? Why Objective C
 
in JSTL
<c: out> in JSTL <c: out> in JSTL...;    One of the general purpose core library tag is <c: out>. The main function of the this tag is to display the output
 
Nested in JSTL
;        The JSP Standard Tag Library (JSTL) core library, provides custom tags for basic functionality. Instead... Nested <c:forEach> in JSTL Nested <c
 
in JSTL
;     The JSP Standard Tag Library (JSTL) core library, provides custom tags for basic functionality. Instead of using those... <c:forEach> in JSTL <c:forEach>
 
Objective-C keywords
Objective-C keywords, Objective C programming language, Objective C Language Objective-C keywords  ... in this section we will know about the keywords used in objective-C language
 
attribute escapeXml
purpose core library tag is <c: out>. The main function of the this tag... <c: out> attribute escapeXml <c: out>...;%= ---%>.  Attributes of the <c: out> core action tag.  value
 
Objective C Constructors
Objective C Constructors, Objective C programming language, Objective C Language Objective C Constructors...; Objective-C enables user to define constructor with the help of self and super
 
Objective C on Mac
Objective C on Mac, Objective C Mac Objective C... and run Objective C program on Mac machine. Compiling Objective C on Mac OS x To Compile Objective-C Programs on Mac OS X This is a simple process to compile
 
Create URL using tag of JSTL Core tag library
Create URL using <c:url> tag of JSTL Core tag library Create URL using <c:url> tag of JSTL Core tag library... given parameter by using <c:url> tag.        
 
For Simple Calculation and Output
; One of the general purpose core library tag is <c: out>. The main function... <c: out> For Simple Calculation and Output <c: out> For Simple Calculation and Output   
 
C++ Compiler for Linux
Eclipse Plugin-Language C++ Compiler for Linux...;   Intel? C++ Compiler Professional Edition offers the best..., OpenMP*, data prefetching, and loop unrolling, along with highly optimized C
 
C GMT Time
C GMT Time C GMT Time...; In this section, you will study how to get the gmt time in C. GMT stands... the current time in seconds and assign it to t. We have used the library function gmtime
 
C file delete example
C file delete example C file delete example...;   This section illustrates you to delete a file in C. You can... have used the library function remove() which deletes the file HELLO.txt. In case
 
C String to Int
C String to Int C String to Int... into an integer represented value in C. You can see in the given example that we have used the library function atoi() provided by the header file <stdlib.h
 
C Array Declaration
C array declaration C Array Declaration...;  In this section, you will learn how to declare an array in C. To declare an array in C, you have to specify the name of the data type
 
Conditional Include with
Conditional Include with <c:if> Conditional Include with <c:if>      ... or not, then in these condition the <c:if> tag is used. In this tag there is no way
 
C file rename
C file rename C file rename...; This section illustrates you to rename a file in C. You can see in the given... with HELLO.txt. For this, we have used the library function rename() which renames the file
 
Exception handling in Objective-C
Exception handling in Objective-C, Objective C programming language, Objective C Language Exception handling in Objective-C...;   Objective-C provide exception handling to handle
 
JSTL c:catch with c:if
JSTL c:catch with c:if JSTL c:catch with c... that solution by yourself. Then then is one tag provided to you that is <c:catch> which is one of the tag of core action library. It works like a try/catch
 
C String Copy
C String Copy C String Copy...; In this section, you will learn how to copy the string in C. You can see... is passed to the st1. Then we have used the library function strcpy() provided
 
Comparing Two String with
Comparing Two String with <c:if> Comparing Two String with <c:if>      ... or not, then in these condition the <c:if> tag is used. This tag
 
C String Concatenation
C String Concatenation C String Concatenation... strings in C. You can see in the given example, we have declared two strings in order to combine the strings. For this, we have used the library function strcat
 
Objective-C Inheritance
Objective-C Inheritance, Objective C programming language, Objective C Language Objective-C Inheritance...; Objective-C enables programmer to inherit common methods and properties
 
Dynamic Types in Objective-C
Objective C, Objective C programming language, Objective C Language Dynamic Types in Objective-C  ...; Objective-C provides many methods to work with dynamic types. With these methods
 
JSTL
JSTL <c: catch> JSTL <c: catch>... from that solution by yourself. Then then is one tag provided to you that is <c:catch> which is one of the tag of core action library. It works like a try
 
AN INTRODUCTION TO JSTL
;  TO   JSTL    (JSP  STANDARD TAG  LIBRARY... tutorial on JSTL, the author  introduces the concept of tag-based programming... of this tutorial on JSTL, the author gives a brief introduction to JSTL and shows why and how
 
JSP JSTL c:if tag
JSP JSTL c:if tag JSP JSTL c:if tag... in jsp.  The c:if tag is used for a decision need, to be made in the page.../core" prefix="c" %> <html> <body> <form method="post">Guess
 
with No Body
<c:If> with No Body <c:If> with No Body... or not, then in these condition the <c:if> tag is used. The problem with <c:if>... value. The <c:if> tag is not for applicable if we want to do one thing
 
Open Source c++
yet, (too busy) but will have them in soon. I provide the C++ library source...;       Open Source C++ GUI Programming Qt3 The Qt toolkit is a C++ class library and a set of tools for building
 
C Structure Pointer
C Structure Pointer C Structure Pointer            ...;  This section illustrates you the concept of Structure Pointer in C
 
Use of tag of Core JSTL tags
<c:catch> is member of Core tag library of JSTL so before use Core JSTL tags... Use of <c:catch> tag of Core JSTL tags Use of <c:catch> tag of Core JSTL tags     
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.