Eine By: Avinash Reddy 09/29/2016.

Slides:



Advertisements
Similar presentations
Chapter 7: User-Defined Functions II
Advertisements

1 Review of Class on Oct Outline  Pointer  Pointers to void  Call-by-Reference  Basic Scope Rules  Storage Classes  Default Initialization.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Chapter 6. 2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single Value Pass by Reference Variable Scope.
Lecture 9 Concepts of Programming Languages
Introduction to Classes and Objects CS-2303, C-Term Introduction to Classes and Objects CS-2303 System Programming Concepts (Slides include materials.
1 Functions Modules: functions and classes Programs use new and “prepackaged” modules –New: programmer-defined functions, classes –Prepackaged: from the.
1 Classes and Objects. 2 Outlines Class Definitions and Objects Member Functions Data Members –Get and Set functions –Constructors.
Review of C++ Programming Part II Sheng-Fang Huang.
February 27, 2014CS410 – Software Engineering Lecture #8: C++ Basics II 1 The vector Container Type When a vector is created, its elements are initialized.
March 4, 2014CS410 – Software Engineering Lecture #9: C++ Basics III 1 Today’s Topics The operators new and deleteThe operators new and delete The scope.
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single.
CS212: Object Oriented Analysis and Design Lecture 6: Friends, Constructor and destructors.
 2006 Pearson Education, Inc. All rights reserved Classes: A Deeper Look, Part 2.
SEN 909 OO Programming in C++ Final Exam Multiple choice, True/False and some minimal programming will be required.
Functions Kernighan/Ritchie: Kelley/Pohl: Chapter 4 Chapter 5.
CS212: Object Oriented Analysis and Design Lecture 7: Arrays, Pointers and Dynamic Memory Allocation.
Defining and Converting Data Copyright Kip Irvine, 2003 Last Update: 11/4/2003.
Learners Support Publications Classes and Objects.
Chapter 9 Pointers and Dynamic Arrays (9.1). Pointers A variables which holds the memory address for a variable of a specific type. Call-by-Reference.
C++ Class Members Class Definition – class Name – { – public: » constructor(s) » destructor » function members » data members – protected: » function members.
1 Announcements Note from admins: Edit.cshrc.solaris instead of.tcshrc Note from admins: Do not use delta.ece.
C++ Programming Lecture 11 Functions – Part III By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
1 Chapter Four Creating and Using Classes. 2 Objectives Learn about class concepts How to create a class from which objects can be instantiated Learn.
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.
1 Classes II Chapter 7 2 Introduction Continued study of –classes –data abstraction Prepare for operator overloading in next chapter Work with strings.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Chapter 4: More Object Concepts. Objectives Understand blocks and scope Overload a method Avoid ambiguity Create and call constructors with parameters.
Introduction to Classes in C++ Instructor - Andrew S. O’Fallon CptS 122 Washington State University.
1 Chapter 8 Scope, Lifetime, and More on Functions CS185/09 - Introduction to Programming Caldwell College.
Object Lifetimes and Dynamic Objects Lecture-7. Object Lifetimes and Dynamic Objects External (Global) Objects Persistent (in existence) throughout the.
Advanced Programming in C
Memory Management.
Constructors and Destructors
Classes (Part 1) Lecture 3
Structures Revisited what is an aggregate construct? What aggregate constructs have we studied? what is a structure? what is the keyword to define a structure?
Abstract Data Types and Encapsulation Concepts
IS Program Design and Software Tools Introduction to C++ Programming
C Functions -Continue…-.
CSC241: Object Oriented Programming
Friend Class Friend Class A friend class can access private and protected members of other class in which it is declared as friend. It is sometimes useful.
COM S 326X Deep C Programming for the 21st Century Prof. Rozier
CS410 – Software Engineering Lecture #11: C++ Basics IV
Structures Revisited what is an aggregate construct? What aggregate constructs have we studied? what is a structure? what is the keyword to define a structure?
Object Lifetime and Dynamic Objects
Instructor: Ioannis A. Vetsikas
This pointer, Dynamic memory allocation, Constructors and Destructor
Lecture 4-7 Classes and Objects
Lecture 9 Concepts of Programming Languages
Abstract Data Types and Encapsulation Concepts
Chapter 5 - Functions Outline 5.1 Introduction
Scope, Parameter Passing, Storage Specifiers
Object Oriented Programming COP3330 / CGS5409
Abstract Data Types and Encapsulation Concepts
CS212: Object Oriented Analysis and Design
Dr. Bhargavi Dept of CS CHRIST
Constructors and Destructors
Classes and Objects.
Classes, Constructors, etc., in C++
UNIT I OBJECT ORIENTED PROGRAMMING FUNDAMENTALS
Operator Overloading Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition,
Scope Rules Of Variables
Submitted By : Veenu Saini Lecturer (IT)
The vector Container Type
Recitation Course 0603 Speaker: Liu Yu-Jiun.
CS410 – Software Engineering Lecture #5: C++ Basics III
C Programming Lecture-17 Storage Classes
SPL – PS3 C++ Classes.
Lecture 9 Concepts of Programming Languages
Introduction to Classes and Objects
Presentation transcript:

Eine By: Avinash Reddy 09/29/2016

Concept Current Applications, gives a unstructured way of Sharing pictures with bit of vagueness often do not fully relate the experience of a day Our social networking application allows a user to share an entire experience of a process or theme of an activity, rather than vague snaps Putting a intrinsic structure to share an process of what users wish to do Set and assign Themes for a day

Intrinsic Productivity Social Application Intrinsic Productivity Eine

Theme + Time + Photos Eine

Assign + Time + Photos Eine

Project Requirements Web Development iOS App Development

Conclusion Sharing the entire process of what you actively wish to do is very important. Also being social, should have a intrinsic by-product of improving our lifestyle.

Thank You

CS410 – Software Engineering Lecture #9: C++ Basics III Today’s Topics Storage classes The operators new and delete The scope resolution operator Nested classes Static and const members The “this” pointer Constructors and destructors September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

CS410 – Software Engineering Lecture #9: C++ Basics III Storage Classes Every variable and function in the C++ kernel language has two attributes: type and storage class. The four storage classes are automatic, external, register, and static. Variables are assigned a storage class by placing the corresponding keyword before the type specifier. Examples: auto int a, b, c; extern float f = 7.22; September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

CS410 – Software Engineering Lecture #9: C++ Basics III The Storage Class auto Variables declared within function blocks are by default automatic. Therefore, automatic is the most common of the four storage classes. Automatic variables can be acted on within the scope of the enclosing block. September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

The Storage Class extern If we want to transmit information across blocks and functions, we can use external variables. When a variable is declared outside a function at the file level, storage is assigned to it permanently, and its storage class keyword is extern. Such a variable is considered to be global to all functions declared after it. The keyword extern is used to tell the compiler, “Look for it elsewhere, either in this file or in another one.” September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

The Storage Class register The storage class register tells the compiler that the associated variable should be stored in high-speed memory registers. This is not always possible. Increases time efficiency of manipulating this variable. Optimizing compilers assign register storage classes by themselves. September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

The Storage Class static Static variables retain their previous value when their block is re-entered. Static functions are visible only within the file in which they are defined. Therefore, the static storage class provides a privacy mechanism that is very important for program modularity. September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

The Operators new and delete The unary operators new and delete are available to manipulate free store. They are more convenient than the C functions malloc(), calloc(), and free(). Free store is a system-provided memory pool for objects whose lifetime is directly managed by the programmer. This adds responsibility to the programmer and can easily lead to problems such as memory leaks. On the other hand, manipulating free store is an efficient and flexible way to handle data structures such as trees and lists. September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

The Operators new and delete The programmer creates an object using new, and destroys the object using delete. The operator new is typically used in the following forms: new type-name new type-name initializer new type-name [expression] In each case, there are at least two effects: An appropriate amount of store is allocated from free store to contain the named type. The base address of the object is returned as the value of the new expression. September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

The Operators new and delete Example: … int *p, *q; p = new int(5); q = new int[10]; In this code, the pointer variable p is assigned the address of the store obtained, The location pointed at by p is initialized to the value 5, the pointer variable q is assigned the base address of an int array of size 10. September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

The Operators new and delete Notice the following things: When memory is unavailable, the operator new can either throw a bad_alloc exception or return the value 0. If no initializer is provided, the content of the allocated memory is undefined. Arrays cannot be initialized using the new operator. Objects created by the new operator always need to be destroyed by the delete operator as soon as they are not used by the program any more. September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

The Operators new and delete The operator delete destroys an object created by new. This returns its allocated storage to free store for reuse. The operator delete is used in the following forms: delete expression delete [] expression The first form is used when the corresponding new expression has not allocated an array. The second form (empty brackets) is used when the original allocation was an array. The return type of delete is void (no return value). September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

The Operators new and delete Example: Dynamic allocation of an array int main() { int *data; int size; cout << “\nEnter array size: “; cin >> size; assert(size > 0); data = new int[size]; assert(data != 0); for (int j = 0; j < size; j++) cout << (data[j] = j) << ‘\n’; delete [] data; return 0; } Starting the program: Enter array size: 4 1 2 3 September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

The Scope Resolution Operator The concept of classes adds new scope rules to those of the kernel language. You remember that one point of classes is to provide an encapsulation technique. It makes sense that all names declared within a class be treated within their own scope as distinct from external names, function names, and other class names. This creates the need for the scope resolution operator. September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

The Scope Resolution Operator The scope resolution operator is the highest-precedence operator in the C++ language. It comes in two forms: ::j (unary operator – refers to external scope) MyClass::j (binary operator – refers to class scope) Its unary form is used to access a name that has external scope and has been hidden by local or class scope. September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

The Scope Resolution Operator Example: int count = 0; void how_many(double w[], double x, int &count) { for (int i = 0; i < N; i++) count += (w[i] == x); // local count ++ ::count; // global count tracks calls } September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

The Scope Resolution Operator To better understand this program fragment, we change the parameter int &count to int &cnt: int count = 0; void how_many(double w[], double x, int &cnt) { for (int i = 0; i < N; i++) cnt += (w[i] == x); // local count ++count; // global count tracks calls } September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

The Scope Resolution Operator Binary scope resolution is used to clarify names that are reused within classes. For example, we need scope resolution to define member functions: class Student { public: void PrintName(); private: string studentName; }; void Student::PrintName() { cout << studentName; } September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

CS410 – Software Engineering Lecture #9: C++ Basics III Nested Classes Like blocks and namespaces, classes are scopes and can nest. Nesting allows local hiding of names and local allocation of resources. This is often desirable when a class is needed as part of the implementation of a larger construct. September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

CS410 – Software Engineering Lecture #9: C++ Basics III Nested Classes Example: char c; // external scope ::c class X // outer class declaration X:: { public: char c; // X::c class Y // inner class declaration X::Y:: void foo(char e) { X t; ::c = t.X::c = c = e; } private: char c; // X::Y::c }; t.X::c is the same as t.c September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

static and const Members Using the modifier static in declaring a data member means that the data member is independent of any given class variable. The data member is part of the class but separate from any single class object. You remember that nonstatic data members are created for each instance of the class. Using static data allows class data to be scoped to the class but still require only one object for its storage. Without static data members, data required by all instances of a class would have to be global. September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

static and const Members Since static members are independent of a particular instance, they can be accessed in the form class-name :: identifier Example: class Point { public: static int how_many; }; Point::how_many = 0; … ++Point::how_many; September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

static and const Members A static member function has the modifier static precede the return type inside the class declaration. Example: class Foo { static int foo_function(); }; int Foo::foo_function() … } September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

static and const Members A data member declared with the const modifier cannot be modified after initialization. syntactically, a const member function has the modifier follow the argument list inside the class declaration. Example: class Foo { int foo_function() const; }; int Foo::foo_function() const {} September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III

static and const Members The const and static member function implementation can be understood terms of this pointer access. An ordinary member function is invoked as x.fcn(i, j, k). It has an explicit argument list i, j, k and an implicit argument list that includes the members of x (accessible through the this pointer). A static member function does not get the implicit arguments. A const member function cannot modify its implicit arguments. September 29, 2016 CS410 – Software Engineering Lecture #9: C++ Basics III