Class Byteline Ustyugov Dmitry MDSP November, 2009.

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
Advertisements

Chapter 7 Constructors and Other Tools. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 7-2 Learning Objectives Constructors Definitions.
Lists: An internal look
Operator overloading redefine the operations of operators
Constructors and Destructors. Constructor Constructor—what’s this? Constructor—what’s this? method used for initializing objects (of certain class) method.
Constructor. 2 constructor The main use of constructors is to initialize objects. A constructor is a special member function, whose name is same as class.
Contents o Introduction o Characteristics of Constructor. o Types of constructor. - Default Constructor - Parameterized Constructor - Copy Constructor.
Introduction to Programming Lecture 39. Copy Constructor.
Templates in C++ Template function in C++ makes it easier to reuse classes and functions. A template can be viewed as a variable that can be instantiated.
Win32 Programming Lesson 4: Classes and Structures.
Data Structure (Part I) Stacks and Queues. Introduction to Stack An stack is a ordered list in which insertion and deletions are made at one end. –The.
OBJECT ORIENTED PROGRAMMING Instructor: Rashi Garg Coordinator: Gaurav Saxena.
@ Zhigang Zhu, CSC212 Data Structure - Section FG Lecture 10 The Bag and Sequence Classes with Linked Lists Instructor: Zhigang Zhu Department.
Main Index Contents 11 Main Index Contents Container Types Container Types Sequence Containers Sequence Containers Associative Containers Associative Containers.
1 Class Constructors a class constructor is a member function whose purpose is to initialize the private data members of a class object the name of a constructor.
Shallow Versus Deep Copy and Pointers Shallow copy: when two or more pointers of the same types point to the same memory – They point to the same data.
More Classes in C++ Bryce Boe 2012/08/20 CS32, Summer 2012 B.
1 Operator Overloading in C++ Copyright Kip Irvine, All rights reserved. Only students enrolled in COP 4338 at Florida International University may.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes.
CSE 333 – SECTION 4. Overview Pointers vs. references Const Classes, constructors, new, delete, etc. More operator overloading.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 14: Pointers, Classes, Virtual Functions, and Abstract Classes.
1 CSC 222: Computer Programming II Spring 2004 Pointers and linked lists  human chain analogy  linked lists: adding/deleting/traversing nodes  Node.
Operatorsand Operators Overloading. Introduction C++ allows operators to be overloaded specifically for a user-defined class. Operator overloading offers.
March 6, 2014CS410 – Software Engineering Lecture #10: C++ Basics IV 1 Structure Pointer Operator For accessing members in structures and classes we have.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures C++ Review Part-I.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
Pointers and Dynamic Memory Allocation Copyright Kip Irvine 2003, all rights reserved. Revised 10/28/2003.
Chapter 12: Pointers, Classes, Virtual Functions, and Abstract Classes.
1 Recall Definition of Stack l Logical (or ADT) level: A stack is an ordered group of homogeneous items (elements), in which the removal and addition of.
Object Oriented Programming Elhanan Borenstein Lecture #3 copyrights © Elhanan Borenstein.
C/C++ 3 Yeting Ge. Static variables Static variables is stored in the static storage. Static variable will be initialized once. 29.cpp 21.cpp.
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
Class Miscellanea Details About Classes. Review We’ve seen that a class has two sections: class Temperature { public: //... public members private: //...
Review of Last Lecture. What we have learned last lecture? What does a constructor do? What is the way to define a constructor? Can it be defined under.
Data Structures Using C++1 Chapter 3 Pointers and Array-Based Lists.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
What happens... l When a function is called that uses pass by value for a class object like our dynamically linked stack? StackType MakeEmpty Pop Push.
Object-Oriented Programming in C++ Lecture 4 Constants References Operator overloading.
Data Structure Specification  Language independent  Abstract Data Type  C++  Abstract Class.
ICOM 4035 – Data Structures Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department.
1 Chapter 3 Lists, Stacks, and Queues Reading: Sections 3.1, 3.2, 3.3, 3.4 Abstract Data Types (ADT) Iterators Implementation of Vector.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 26 Clicker Questions December 3, 2009.
Chapter 7 Constructors and Other Tools Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
CS162 - Topic #6 Lecture: Pointers and Dynamic Memory –Review –Dynamically allocating structures –Combining the notion of classes and pointers –Destructors.
CMSC 202 Lesson 26 Miscellaneous Topics. Warmup Decide which of the following are legal statements: int a = 7; const int b = 6; int * const p1 = & a;
Object-Oriented Programming Review 1. Object-Oriented Programming Object-Oriented Programming languages vary but generally all support the following features:
Copyright © 2002 Pearson Education, Inc. Slide 1.
Copyright © 2002 Pearson Education, Inc. Slide 1.
Pointers and Dynamic Arrays
Learning Objectives Pointers as dada members
Data types Data types Basic types
Linked Lists Chapter 6 Section 6.4 – 6.6
Andy Wang Object Oriented Programming in C++ COP 3330
CISC181 Introduction to Computer Science Dr
Chapter 5 Classes.
LinkedList Class.
Memberwise Assignment / Initialization
This pointer, Dynamic memory allocation, Constructors and Destructor
Pointers and Linked Lists
Chapter 12: Pointers, Classes, Virtual Functions, and Abstract Classes
Chapter 16-2 Linked Structures
Operator Overloading; String and Array Objects
[Chapter 4; Chapter 6, pp ] CSC 143 Linked Lists [Chapter 4; Chapter 6, pp ]
Constructors and Other Tools
Indirection.
References, const and classes
Dynamic allocation (continued)
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
C++ support for Object-Oriented Programming
Data Structures & Programming
Presentation transcript:

Class Byteline Ustyugov Dmitry MDSP November, 2009

2 Class Byteline  Class Byteline implemented in memory.h –Is used to manipulate with entire byte combinations - bytelines. –Has its own private section –Methods and overloaded operators MDSP project, Intel Lab, Moscow Institute of Physics and Technology

3 Contents  Private section and variables  Constructors and destructors  Methods and overloaded operators  Overloaded operators MDSP project, Intel Lab, Moscow Institute of Physics and Technology

4 Private section and variables private: vector *byte_line;// pointer to vector of //Bytes MDSP project, Intel Lab, Moscow Institute of Physics and Technology

5 Constructors  ByteLine(); –Creates empty object of Byteline class... Byteline example; // an empty object created...  ByteLine( unsigned int); –Creates object of Byteline class with count Byte, initializing with null bytes... Byteline example( 5);// object consisting 5 null bytes created... MDSP project, Intel Lab, Moscow Institute of Physics and Technology

6 Constructors  ByteLine( const ByteLine&); –Copy constructor... Byteline copy( example); // another object equal to the // previous one...  ByteLine( const Byte&); –Conversion constructors Byte in ByteLine... Byteline now_it_is_bl;// object consisting 5 null bytes //created... MDSP project, Intel Lab, Moscow Institute of Physics and Technology

7 Destructor virtual ~ByteLine() { delete byte_line; } MDSP project, Intel Lab, Moscow Institute of Physics and Technology

8 Methods: get/set methods  hostUInt8 getByteVal( unsigned int) const;  Byte getByte( unsigned int) const;  void setByte( unsigned int, const Byte&); MDSP project, Intel Lab, Moscow Institute of Physics and Technology

9 Methods: hostUInt8 getByteVal( unsigned int) const;  The constant member function. Returns the value of the Byte at position pos in the ByteLine.If that position is invalid, recalls exception... // example.byteline is equal to | example.getByteVal( 1) = 10;... MDSP project, Intel Lab, Moscow Institute of Physics and Technology

10 Methods: get/setByte  Byte getByte( unsigned int) const; –Returns the object of class Byte at position pos in the ByteLine. If that position is invalid, recalls exception... (example_byteline: byte2|byte1|byte0|) example_byteline.getByte( 1) = byte1;...  void setByte( unsigned int, const Byte&); –Stores the object of class Byte at position pos in the ByteLine.If that position is invalid, recalls exception... (before: example_byteline: byte2|byte1|byte0|) Example.setByte( 2, newByte); (after: example_byteline: newByte|byte1|byte0|)... MDSP project, Intel Lab, Moscow Institute of Physics and Technology

11 Utility functions  void addByte( const Byte&); –Adds object of Byte class to end of ByteLine... (before: example: byte2|byte1|) example.addByte( byte3); (after: example: byte3|byte2|byte1|)...  void resizeByteLine( unsigned int); –Resize of ByteLine on count. New member of ByteLine is null bytes... (before: example: | |) example.resizeByteLine( 3) // result: | | |...  unsigned int getSizeOfLine() const –The constant member function. Return size of Byteline MDSP project, Intel Lab, Moscow Institute of Physics and Technology

12 Overloaded operators  ByteLine& operator = ( const ByteLine&); –Assign the current object of ByteLine class to another  Byte operator[] ( unsigned int) const; –The constant member function.The member function returns an object of class reference. –Returns the Byte at position pos in the ByteLine. If position is invalid, recalls exception  inline ByteLine operator<< ( const ByteLine& byteline, int count); –Shifts bytes in the byteline left with the count of bytes  inline ByteLine operator>> ( const ByteLine& byteline, int count); –Shifts bytes in the byteline right with the count of bytes MDSP project, Intel Lab, Moscow Institute of Physics and Technology

13 Overloaded Operators: >  inline ByteLine operator<< ( const ByteLine& byteline, int count); –Shifts bytes in the byteline left with the count of bytes... (before: example: | |) example << 3; (after: example: | |)...  inline ByteLine operator>> ( const ByteLine& byteline, int count); –Shifts bytes in the byteline right with the count of bytes... (before: example: | |) example >> 3; (after: example: | |) MDSP project, Intel Lab, Moscow Institute of Physics and Technology

14 Friendly operators  friend ostream& operator<< ( ostream&, const ByteLine&); –Outputs the ByteLine in bin form to screen  friend ByteLine operator+ ( const ByteLine&, const ByteLine&); –Returns the ByteLine to be a result of addition of two objects of class reference... (example1: | |, example: | |) example = example1 + example2 (example: | | | |)... MDSP project, Intel Lab, Moscow Institute of Physics and Technology