Synopsis:
This session provides help with projects, then continues with templates.
We will review basic ideas and then discuss code examples.
Glossary of Terms
-
Function:
A language construct that names a block of processing instructions, passes input arguments for processing, and returns a single argument result. Everytime a function is called, temporary stack memory is allocated for the function to hold its arguments, local data, and return value. When the thread of execution leaves the function, its temporary memory becomes invalid, and, at any time after, may be allocated to another function and be overwritten. -
Class:
A language construct that binds together member functions and data:- Class syntax: class X { ... }
- Method syntax: public void f(T t) { ... }
- Data syntax: private Y y = new Y;
-
Template Function:
A function using an unspecified type parameter, allowing specification with several different specific types without writting a lot of almost duplicate code. Here's an example of template function syntax:template<typename T> void someFunction(T& t) { ... }
-
Template Class:
Classes can be templates and also avoid writing a lot of nearly duplicate code. Here's an example of template class syntax:template<typename T> class SomeClass { ... }
Lecture Content:
-
Help with Projects:
-
Project #1
Single-user Test Harness. -
Project #2
Local Test Harness -
Project #3
Server Process Pools -
Project #4
Remote Multi-User Test Harness
-
Project #1
-
Synchronous Discussion:
- Download, build, and run the Parser project.
- Be prepared to describe how this code works. You will find the Parser Blog helpful.
-
C++ Templates
Quick overview Templates Presentation, pptx
Templates are one of the terrific features of the C++ language. Almost all of the Standard Template Library (STL) is implemented with templates, and they are very useful in day-to-day programming. fully functional C++ Properties, courtesy of templates
This project demonstrates how easy it is to extend the C++ language. C++ doesn't natively support properties but it's not hard to provide them. First template demo
Provides a simple type to string conversion facility. Template Code Examples
Basic and some more advanced template examples. STL Container examples
This code contains a simple example of the new Variadic Template functionality in the "inserter" project. Survey of STL Container Classes
Simple demos of almost all of the STL containers. STL Template-based Functors and Algorithms
Another set of template code examples, including functors, algorithms, and several other things you need to know. Functor examples Excellent template Q&A
This is a good place to find information to supplement class texts and notes. -
Lecture Take-away
The most important things we discussed today are: Next time we will continue with class relationships. Please look at: