C++ Programming Tutorial

 
 
 

Object Oriented Programming

Structures

Example of structures Passing structures to function Passing structure pointers to function Pointers and an array of structure Relationship between union and structure Array of structure Nested structures Self-referential structures Linked List

Classes

Classes with inline functions Classes without using inline functions Example of constructor in classes Passing values to constructor in classes Overloading of constructors in classes Example of destructor in classes Example of static class data Example of static member functions Constant objects, constant member functions Strings as member of classes Use of arrays as data items in classes Example of array of objects in classes Use of pointer this using header file this.h Obj initialize, assign by default member wise copy

Inheritance - Containership

Example of Inheritance Over riding base class member fn in derived Diff in public, protected, private inheritance Multi-level inheritance Multiple inheritance Example of containership

Virtual Functions - Polymorphism

Example of Polymorphism Example of Pure Virtual functions

Operator Overloading - Type Casting

Increment operator ++ overloading w/o return type Increment operator ++ overloading - return type Decrement operator -- overloading w/o return type Decrement operator -- overloading - return type Operator overloading for strings Comparision operator < overloading Binary operator + overloading creating new object Binary operator + overloading w/o creating object Binary operator - overloading creating object Binary operator - overloading w/o creating object Binary operator * overloading w/o creating object Stream insertion >> , extraction << operators Data conversion b/w built-in data types Data conversion - built-in, user defined data type Conversion- built-in, user defined data type- char Data conversion user defined data type - function Conversion user defined data type - constructor

Friend Functions and Classes

Use of friend functions Use of friend classes Operator overloading using friend function All Operator overloading using friend function Addition of 2 matrix using friend function Example of friend function of a class

Template Functions and Classes

Interchange value using function template Example of template classes Template based array input Template to find minimum value in an array Template of vector class

File Processing - Command Line Arguments

Open file File operation program - diff type of mode Read from one text file, writing in new text file File read, write, update and display operations Read decimal from file - convert into hexadecimal Read words from file and remove palindrome Read device data from text file and show extension Example of binary files

General Programs

Number of days b/w two given dates Capitalize first charcter of every word in string Copy n num of characters from one to another Word is palindrome or not using classes & pointers Simulation of the Solar System Add and Subtract functions on Big Number Class
 
 

Image

//MAKING FILE PROGRAM WITH USING ALL MODES

#include <iostream.h>
#include <fstream.h>
#include <conio.h>

static int totrec=0;    //totrec variable keep track for total variable entered
            //Initially Record scanned are Zero

void main()
{
int choice;
while(1)
{
clrscr();
cout<<\"Choose your choice\\nNOTE : one choice for one record(except viewing data)\\n\";
cout<<\"1) Scanning intial records\\n\";
cout<<\"2) Appending records\\n\";
cout<<\"3) Modifying or append records\\n\";
cout<<\"4) Viewing records\\n\";
cout<<\"5) Exit\\n\";
cout<<\"Enter your choice : \";
cin>>choice;
switch (choice)
{
  case 1 :   {
         ofstream outfile;
         outfile.open(\"emp\",ios::out);
         cout<<\"\\n\\nPlease enter the details as per demanded\\n\";
         cout<<\"\\nEnter the name : \";
         char name[20];
         cin>>name;
         outfile<<name<<endl;
         cout<<\"Enter Age : \";
         int age;
         cin>>age;
         outfile<<age<<endl;
         cout<<\"Enter programming language known by him\\her : \";
         char lang[25];
         cin>>lang;
         outfile<<lang<<endl;
         totrec= totrec + 1;
         outfile.close();
         }
         break;
  case 2 :   {
         ofstream outfile;
         outfile.open(\"emp\",ios::app);
         cout<<\"\\n\\nPlease enter the details as per demanded\\n\";
         cout<<\"\\nEnter the name : \";
         char name[20];
         cin>>name;
         outfile<<name<<endl;
         cout<<\"Enter Age : \";
         int age;
         cin>>age;
         outfile<<age<<endl;
         cout<<\"Enter programming language known by him : \";
         char lang[25];
         cin>>lang;
         outfile<<lang<<endl;
         totrec = totrec + 1;
         outfile.close();
         }
         break;
  case 3 :   {
         ofstream outfile;
         outfile.open(\"emp\",ios::ate);
         cout<<\"Are you interested in adding record\\nenter y or n\\n\";
         char ans;
         cin>>ans;
         if(ans==\'y\' || ans==\'Y\')
         {
         cout<<\"\\n\\nPlease enter the details as per demanded\\n\";
         cout<<\"\\nEnter the name : \";
         char name[20];
         cin>>name;
         outfile<<name<<endl;
         cout<<\"Enter Age : \";
         int age;
         cin>>age;
         outfile<<age<<endl;
         cout<<\"Enter programming language known by him : \";
         char lang[25];
         cin>>lang;
         outfile<<lang<<endl;
         totrec = totrec + 1;
         }
         outfile.close();
         }
         break;
  case 4 :   {
         ifstream infile;
         infile.open(\"emp\",ios::in);
         const int size=80;
         char line[size];
         int counter=totrec;
         while(counter > 0)
         {
         infile.getline(line,size);
         cout<<\"\\n\\nNAME     : \"<<line<<endl;
         infile.getline(line,size);
         cout<<\"AGE      : \"<<line<<endl;
         infile.getline(line,size);
         cout<<\"LANGUAGE : \"<<line<<endl;
         counter--;
         }
         infile.close();
         }
         getch();
         break;
  case 5  :  goto out;
  default :  cout<<\"\\nInvalid Choice\\nTRY AGAIN\\n\";
  }
}
out:
}

    Related Post:
  1. Program to read a Linear System of Equations,then evaluate it by using Guass-Seidel Itrative Method and show the result

  2. Program to illustrate the use of inline functions

  3. Program to compute nCr

  4. Program to computes the n_th term of the fibonacci series using Dynamic Programming Technique

  5. Program to illustrate the binary operator(*) overloading without creating a new object

  6. Program to illusrate comparision operator overloading

  7. Program that takes input of vector elements and performs multiplication operation, and input/output (&gt;&gt;, &lt;&lt;) using operator overloading

  8. Program to illustrate an array of structure

  9. Program to create a queue using static memory allocation

  10. Program to illustrate the implementation of arrays as a Stack in graphics

  11. Program that takes input of counter and displays output of incremented counter using overloading operator++

  12. Program to perform linear sort

  13. Program to illustrate use of arrays as data items in classes

  14. Program to construct Lagrangess Interpolation Formula from the given distinct data points.

  15. Program to print an array before and after adding 5 to its contents using pointers

  16. Program to illustrate the binary operator(-) overloading without creating an object of that class

  17. To parse a string using Operator Precedence parsing

  18. Program to fill different types of geometric shapes using Boundary Fill Algorithm

  19. Program to illustrate the implementation of Rotation Transformation

  20. Program that calculates area of triangle and rectangle using inheritance

 
 
Didn't find what you were looking for? Find more on File Operation Program