Posts

Showing posts from April, 2017

C++ Input/Output : Streams

Image
This blog has been migrated to learn c programming for beginners In this article, you will learn about Streams Based Input/Output in C++ . The input/output operations which involve keyboard as input device and screen as output device are known as Console I/O operations . The input/output operations which involve file as input device and output device are known as File I/O operations C++ Input/Output implement concept of stream .It is an object-oriented alternative to C's FILE-based streams from the C standard library.Stream is the sequences of bytes or flow of data , which acts as a source from which the input data can be obtained by a program or a destination to which the output data can be sent by the program. Input Stream : It is flow of data bytes from a device (e.g Keyboard , disk drive) to main memory Output Stream : It is flow of data bytes from main memory (i.e program) to a device Stream Class Hierarchy Stream class is the collection of data and

Exception Handling

Image
This blog has been migrated to learn c programming for beginners In this article, you will learn about Exception Handling in C++ and which handle run time error. Exception Handling is the mechanism that separate the code that detects and handle exceptions at run time from rest of program C++ exception handling is built upon three keywords: try, catch, and throw. Exception Handling vs Traditional Error Handling Following are main advantages of exception handling over traditional error handling. 1) Separation of Error Handling code from Normal Code: In traditional error handling codes, there are always if else conditions to handle errors. These conditions and the code to handle errors get mixed up with the normal flow. This makes the code less readable and maintainable. With try catch blocks, the code for error handling becomes separate from the normal flow. 2) Functions/Methods can handle any exceptions they choose: A function can throw many exceptions, but may choose to handle s

Tempaltes

This blog has been migrated to learn c programming for beginners In this article, you will learn about Templates in C++ and it's useful for generic programming in C++. Templates are a feature of the C++ programming language that allows single functions and classes to handle different data types. This helps you to write generic programs. Generic Programming Generic programming is a style of computer programming in which program are not compiled as it is but rather 'Templates' of source code are transform into source code at the time of compilation according to supplied datatype as parameters In Templates of C++ template of class or function is defined with general data type and is replaced by a specified data type at the time of actual use of class or function , Hence it follow Generic programming An Example to Begin With This program add two number of different data type according to type of supplied argument Output Result of adding two float : 13.7 Result of add