cs6311 pds lab manual

Upload: ranjith-kumar

Post on 07-Oct-2015

49 views

Category:

Documents


0 download

DESCRIPTION

PDS LAB MANUAL

TRANSCRIPT

CS6311 - PROGRAMMING & DATA STRUCTURESLABORATORY - II1. C++ program for Constructors 2. C++ program for Friend Function and Friend class a) Program for friend function b) program for friend class 3. C++ Program for Inheritance a) Single Inheritance b) Multiple Inheritance c) Multi Level Inheritance d) Hybrid Inheritance 4. C++ program for Polymorphism & Function Overloading. a) Polymorphism b) Function Overloading 5. C++ program for Virtual Functions 6. Overloading unary and binary operator using Member function and Non-member function 7. Class and Function template a) Function Template Displaying greatest value using function template b) Class TemplateDisplaying greatest number using class template.8. Exception Handling a) Division by zero b) Division by zero using function c) User defined exception handling

d) Out of range Exceptions e) Program for Arithmetic exception handling 9. STL Concepts a) Container STL Container-vector operatorsSTL Container-vector, swap()Program for Vectorb) Allocator c) Iterator Iterator - a list container Iterator - a set container Iterator - a multi-set container Iterator - a map container Iterator - a multi-map container d) Function Adaptors 10. Filestream Concepts a) Program to write a text in the file b) Program to read data from text file and display it c) Program to count number of characters from out.txt. d) Program to count number of words from out.txt e) Program to count number of lines in the file f) Program to copy contents of one file to another file. g) Binary file(Write mode) h) Binary file(Read mode) i) Reading from and writing the personal details into the file using getline function j) Reading from and writing into the file

11) Application of Stack & Queue a) Stack Implementation b) Queue Implementation c) Infix to Postfix Conversion: d) Evaluation of Postfix Expression e) Circular Queue Application of queue 12) Implementation of Binary search tree 13. Implementation of Tree Traversal 14. Minimum Spanning Tree a) Prim's Algorithm b) Kruskal Algorithm 15. Shortest Path Algorithm a) Dijkstra's Algorithm b) Bellman Ford Algorithm c) Floyds Warshall Algorithm

1. C++ program for Constructors#include#includeusing namespace std;//class nameclass StudentDetails{//access specifier private://declaration of member variables int mStudentmarks;char mStudentgrade; char* pStudentname; int mName;public://default constructor StudentDetails (){}//parameterized constructorStudentDetails (int student_mark, char student_grade){mStudentmarks = student_mark; mStudentgrade = student_grade;}//copy constructorStudentDetails (StudentDetails & oStudent){mStudentmarks = oStudent.mStudentmarks;

mStudentgrade = oStudent.mStudentgrade;}//dynamic constructorStudentDetails (char* pStudent){mName = strlen(pStudent);pStudentname = new char[mName+1];strcpy(pStudentname,pStudent);}//member function void StudentName(){cout ";cout