C++ File Processing

October 27, 2015 Posted by WithU Technologies
We will learn to read and write files from C++ in this chapter. To do that, first of all we need to include a header file from Standard C++ Library named fstream. fstream is combined with two data separate library files which are: ·         ofstream – Output file stream that creates and writes information to files. ·        ...

C++ Exceptions

October 27, 2015 Posted by WithU Technologies
There are several problems that occur during program execution or after user input which will crash or terminate the program without any clue for that if we do not apply exceptions handling methods to handle those exceptions. C++ exceptions is built with three keywords: try{ throw catch(){ } try – try block is used before the block of code where exceptions may generate after execution. It...

C++ Template Specialization

October 27, 2015 Posted by WithU Technologies
When we use regular templates for functions or classes. The templates handle different data types in the same way as the same code is used for compilation of all data types. But in case we need a specific data type for a particular argument or parameter. We use the method of Template specialization where we override the default template implementation to handle a particular type in a different way. It...

C++ Class Templates

October 27, 2015 Posted by WithU Technologies
As like the function templates we can define a class template with the help of same syntax we learned in the previous chapter.  Example: #include <iostream> using namespace std; template<class R>    //alternative template<typename R> class DisplayGreater{ private:   R a,b;   //two generic private member variables declared public:  ...

C++ Function Templates

October 27, 2015 Posted by WithU Technologies
Till now we already work with many functions and in every program there is at least one default function i.e. the main function. As you know that we have declare a return type and parameters to declare a function. Example: #include <iostream> using namespace std; int show(int a){       return a; } int main() {       int x = 5;      ...