/
GANESAR COLLEGE OF ARTS AND SCIENCE GANESAR COLLEGE OF ARTS AND SCIENCE

GANESAR COLLEGE OF ARTS AND SCIENCE - PowerPoint Presentation

ariel
ariel . @ariel
Follow
66 views
Uploaded On 2023-07-22

GANESAR COLLEGE OF ARTS AND SCIENCE - PPT Presentation

MELAISIVAPURI DEPARTMENT OF COMPUTER SCIENCE PROGRAMMING IN C UNIT V STANDARD TEMPLATE LIBRARY Introduction STL stands for standard template library Collection of these generic classes and functions is called STL ID: 1010190

objects string software object string objects object software oriented design data strings development iterators creating list system analysis process

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "GANESAR COLLEGE OF ARTS AND SCIENCE" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

1. GANESAR COLLEGE OF ARTS AND SCIENCEMELAISIVAPURIDEPARTMENT OF COMPUTER SCIENCE

2. PROGRAMMING IN C++ UNIT - V

3. STANDARD TEMPLATE LIBRARY

4. IntroductionSTL stands for standard template library.Collection of these generic classes and functions is called STL.Large and complexUsing STL can save considerable time and effort and lead to high quality programsnamespace directive ex :- using namespace std;

5. Components of STLThe STL has three components, Containers -hold data Algorithms -manipulating data Iterators - access data

6. CONTAINERSA Container is an object that actually stores dataIt is a way data is organized in memoryHold the difference types of data Container has grouped into three categories:Sequence containers store elements in a linear sequence three types of sequence containers, - vector - list - Dequeue

7. Associative containersIt was designed to support direct access to elements using keys.Not sequential Four types of Associative containers -set -multiset -map -multimap

8. Derived containersSTL has provide three types of derived containers -stack -queue -priority _queue Two member fuctions are used pop() and push() for implementing deleting inserting operations.

9. AlgorithmsIt is a procedureUsed to process the data contained in the containers.Such as initializing, searching, copying, sorting, and merging.Using algorithms, programmers can save a lot of time and effort

10. Categorized the algorithmsRetrieve or nonmutating algorithms Mutating algorithmsSet algorithmsRelational algorithms Sorting algorithms

11. IteratorsAccess the container elementsTraverse from one element to anotherA process known as iterating through the container Iterators function: Input iterators -simplest and is used mostly in single-pass algorithms.

12. output iterators -same as input iterators but not used for traversing.Forward iterators -can be used only in forward direction, one step at a time.Bidirectional iterators -these iterators can move in both directions.Random access itertors -same as pointers . Can be used to any element randomly.

13. Application of container classesThree types of containers are supported in theSTL,-Vectorschange its size dynamically supports random accessNumber of constructors for creaating Vector oobjects, vector<int> v1; //zero-length int vector vector<double> v2; //10-element double vector

14. -listsIt is a another container is popularly used List can be accessed sequentially only Bidirectional iterators are used for accessing list elements Any algorithm that requires input, output, forward, or bidirectional iterators can operate on a list The objects of list can be initialized with other list objects, list A = list1; list B =list2;The statement, list1.merge(list2);

15. -Maps A map is a sequence of (key , value) pairsWhere a single value is associated with each unique key Retrieval of values is based on the key and is very fast : :Key 1Key 2 Value 1Value 2Key NValue N

16. MANIPULATING STRINGS

17. IntroductionA string is a sequence of characterC++ does not support a built – in string typeThe strings are called C-strings or C-style strings.ANSI standard c++ now provides a new class called string .The string class is very large and includes many constructors, member functions, and operators. Follow,

18. Creating string objectsReading string object from keyboard Displaying string objects to the screenFinding a substring from a string Modifying string objectsComparing string objectsAdding string objectsAccessing characters in a string Obtaining the size of stringsMany other operations

19. String constructor String(); -for creating an empty string String(const chat*str); -for creating a string object from a null-terminated string String(const string & str); -for creating a string object from sother string object Important function of string class assign() assigns a partial string Begin() returns a reference to the start of a string End() returns a reference to the end of a string Erase() removes characters as specified Insert() inserts characters at as specified location

20. Operators for string objects Operator meaning = assignment + concatenation+= concatenation assignment== equality!= inequality < less than <= less than or equal<< output>> input

21. Creating (string) objects We can creating string objects in a number of ways as illustrated below : String s1; // using constructor with no argument String s2 (“xyz”) ; // using one –argument constructor S1 =s2 ; // assigning string objectsG3 = “abc” + s2 // concatenating strings Cin >> g1 ; // reading through keyboard (one word)Getline (cin, s1); // reading through keyboard a line of textOverloaded +operator concatenates two string objects .Examples : s3 += s1; //s3 = s3 + s1 S3 += “abc” ; // s3 =s3 + “ abc”

22. MANIPULATING STRING OBJECTSWe can modify contents of string objects in several ways, using the member functions such as insert(),replace(),erase(), and append().Example program :#include <iostream.h>#include <string>using namespace std;Void main(){String s1(“1234”);String s2(“abcd”);

23. cout << “original strings are: \n”cout << “S1: “ << s1 << \n”;cout << “S2: “ << s2 << \n\n”;// inserting a string in to anothercout << “place S2 inside s1 \n”;s1.insert(3,s2);Cout << modified S1: “ << s1 << “ \n\n”;// removing characters in a stringCout << “ remove 4 characters from S2 \n”;s1.erase(3,4);cout << “ Now S1 : “ << “\n\n”;

24. getch(); }Output:Original stringsS1: 1234S2: abcdPlace S2 inside S1Modified S1: 123abcd4Remove 4 characters from S1 Now s1 : 1234

25. Relational operationsA number of operators that can be used on strings are defined for string objects Examples the operator =and + for creating objects Compare() function can also be used for this strings String characteristics Characteristics of strings such as size , length , capacity , etc.The size or length denotes the number of elements currently stored in a given strings.Another characteristic is the maximum size which is the largest possible size of a string object.

26. comparing and swappingThe string supports two functionsComparing - used for to compare either two strings or portions of two strings Swapping - used for swapping the contents of two string objects.

27. OBJECT ORIENTED SYSTEM DEVELOPMENT

28. Introduction Software engineers have been trying various tools, methods, and procedures to control the process of software development in order to build high quality software with improved productivity. The methods provide “how to s” for building the software while the tools provide automated or semi-automated support for the methods. They are used in all the stages of software development process, namely, planning, analysis, design, development and maintenance.

29. Software development components Software development ProceduresMethodsTools

30. A successful system must: 1. satisfy the user requirements, 2. be easy to understand by the users and operators, 3. be easy to operate, 4. have a good user interface, 5. be easy to modify, 6. be expandable, 7. have adequate security controls against misuse of data, 8. handle the errors and exceptions satisfactorily, and

31. Procedure-Oriented Paradigms Software development is usually characterized by a series of stages depicting the various asks involved in the development process.Problem Definition: -This activity requires a precise definition of the problem in user terms. -A clear statement of the problem is crucial to the success of the software. -It helps not only the development but also the user to understand the problem better.

32. Analysis: -This covers a detailed study of the requirements of both the user and the software.Design: -The design phase deals with various concepts of system design such as data structure, software architecture, and algorithms. -This phase translates the requirements into a representation of the software. Coding: -coding refers to the translation of the design into machine-readable form. -its reliability.

33. Testing: -once the code is written, it should be tested rigorously for correctness of the code and results.. -It requires a detailed plan as to what, when and how to test. Maintenance: -This may occur due to a change in the user’s requirement, a change in the operating environment, or an error in the software that has been fixed during the testing.

34. Procedure-Oriented Development Tools System flowcharts: A graphical representation of the important inputs, outputs, and data flow. Program flowcharts: A graphical representation of program logic. Play script: A narrative description of executing Layout forms: A format designed for putting the input data or displaying results. .

35. Data flow diagrams: The flow of data between various components of a system. Decision table: A table of configurations for defining a problem and the actions to be taken. Grid charts: A chart showing the relationship between different modules of a system.

36. Object-Oriented Paradigm A system can be viewed as a collection of entities that interact together to accomplish certain objectives. Entities may represent physical objects such as equipment and people, and abstract concepts such as data files and functions. In object oriented analysis, the entities are called objects.

37. Object oriented software development functions Object-oriented analysis (OOA) refers to the methods of specifying requirements of the software in the terms of real-world objects, their behavior, and their interactions. Object-oriented design (OOD), on the other hand, turns the software requirements into specifications for objects and derives class hierarchies from which the objects can be created. object-oriented programming (OOP) refers to the implementation of the

38. Object-Oriented Notation and GraphsGraphical notations are an essential part of any design and development process, and object-oriented design is no exception. We need notations to represent classes, objects, subclasses, and their inter-relationships

39. some of the commonly used notations to represent the following: 1. Classes and objects. 2. Instances of objects. 3. Message communication between and objects. 4. Inheritance relationship. 5. Classification relationship. 6. Composition relationship. 7. Hierarchical chart. 8. Client-Server relationship. 9. Process layering.

40. ABInheritance relationshipBase classDerived class

41. Client – server relationshipXYServerclient

42. Object–Oriented Analysis Object-oriented analysis provides us with simple, yet powerful, mechanism for identifying objects.The object-oriented analysis (OOA) approach consists of the following steps: 1. Understanding the problem. 2. Drawing the specification of requirement of the user and the software. 3. Identifying the objects and their attributes. 4. Identifying the services that each object is expected to provide (interface). 5. Establishing inter-connections (collaborations) between the objects.

43. Object-Oriented Design Design is concerned with a mapping of objects in the problem space into objects in the solution space, and creating an overall structure and computational models of the system. The object oriented design (OOD) approach may involve the following steps:

44. 1.Review of objects created in the analysis phase. 2. Specification of class dependencies. 3. Organization of class hierarchies. 4. Design of classes. 5. Design of member functions. 6. Design of driver program.