A simple function.

Slides:



Advertisements
Similar presentations
Classes & Objects INTRODUCTION : This chapter introduces classes ; explains data hiding, abstraction & encapsulation and shows how a class implements these.
Advertisements

1 Pointers and Strings Section 5.4, , Lecture 12.
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.
Introduction to Programming Lecture 15. In Today’s Lecture Pointers and Arrays Manipulations Pointers and Arrays Manipulations Pointers Expression Pointers.
1 Structures. 2 User-Defined Types C provides facilities to define one’s own types. These may be a composite of basic types ( int, double, etc) and other.
Chapter 9 Pointers and Dynamic Arrays. Overview 9.1 Pointers 9.2 Dynamic Arrays.
A pointer is the memory address of a variable. A memory address is a physical location within a system’s memory space. A pointer variable is variable used.
PZ09B Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ09B - Parameter transmission Programming Language Design.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 7- 1 Overview 7.1 Introduction to Arrays 7.2 Arrays in Functions 7.3.
Defining classes and methods Recitation – 09/(25,26)/2008 CS 180 Department of Computer Science, Purdue University.
CSC Programming for Science Lecture 30: Pointers.
Pointers and References (1) THE REFERENCE OPERATOR REFERENCES POINTERS THE DEREFERENCE OPERATOR DERIVED TYPES RETURNING A REFERENCE.
Chapter 3 Using Classes and Objects. 2 Creating Objects  A variable holds either a primitive type or a reference to an object  A class name can be used.
Pointers Example Use int main() { int *x; int y; int z; y = 10; x = &y; y = 11; *x = 12; z = 15; x = &z; *x = 5; z = 8; printf(“%d %d %d\n”, *x, y, z);
1/25 Pointer Logic Changki PSWLAB Pointer Logic Daniel Kroening and Ofer Strichman Decision Procedure.
Values, variables and types © Allan C. Milne v
Semantics CSE 340 – Principles of Programming Languages Fall 2015 Adam Doupé Arizona State University
Pointer Data Type and Pointer Variables. Objectives: Pointer Data Type and Pointer Variables Pointer Declaration Pointer Operators Initializing Pointer.
CSE 232: C++ pointers, arrays, and references Overview of References and Pointers Often need to refer to another object –Without making a copy of the object.
CSC 107 – Programming For Science. Today’s Goal  When lecture over, start understanding pointers  What a pointer is and what it is not  Why pointers.
CSC 107 – Programming For Science. Today’s Goal  When lecture over, start understanding pointers  What a pointer is and what it is not  Why pointers.
Parameter Passing Mechanisms Reference Parameters § §
Prog. techniques. Standard prog. techniques Complex programs can be broken down into simpler parts called “Modules” These come in 2 types,“Procedures”
CSE 232: C++ memory management Overview of Arrays Arrays are the simplest kind of data structure –One item right after another in memory (“contiguous range”
C Programming Lecture 16 Pointers. Pointers b A pointer is simply a variable that, like other variables, provides a name for a location (address) in memory.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X 1 Chapter Array Basics.
Variables and memory addresses
Week 12 Methods for passing actual parameters to formal parameters.
POINTERS IN C. Introduction  A pointer is a variable that holds a memory address  This address is the location of another object (typically another.
CSE 332: C++ pointers, arrays, and references Overview of Pointers and References Often need to refer to another object –Without making a copy of the object.
 Memory setup  Pointer declaration  Address operator  Indirection  Printing addresses or pointers.
7.5 – Radical Expressions. Radical Radical – radical symbol.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 330 Programming Language Structures Operational Semantics (Slides mainly.
C++ for Engineers and Scientists Second Edition Chapter 12 Pointers.
TK1924 Program Design & Problem Solving Session 2011/2012
Introduction to Programming Using C
FIGURE 4-10 Function Return Statements
C Language By Sra Sontisirikit
Student Book An Introduction
Visit for more Learning Resources
Prepared By: G.UshaRani B.Pranalini A.S.Lalitha
Memory and Addresses Memory is just a sequence of byte-sized storage devices. The bytes are assigned numeric addresses, starting with zero, just like the.
Using local variable without initialization is an error.
Pointers and References
Dynamic Memory Allocation Reference Variables
Buy book Online -
C Passing arrays to a Function
FIGURE 4-10 Function Return Statements
2011/11/10: Lecture 21 CMSC 104, Section 4 Richard Chang
4-2 Functions in C In C, the idea of top–down design is done using functions. A C program is made of one or more functions, one and only one of which.
Built-In (a.k.a. Native) Types in C++
Lecture 18 Arrays and Pointer Arithmetic
FIGURE 4-10 Function Return Statements
Initializing variables
C Programming Lecture-8 Pointers and Memory Management
C Programming Pointers
Creating and Using Pointer Variables in C++ By: Ed Brunjes
Parameter transmission
PZ09B - Parameter transmission
Introduction to Data Structures and Software Engineering
FIGURE 4-10 Function Return Statements
Pointers and References
Parameter transmission
Pointers, Dynamic Data, and Reference Types
C# Language & .NET Platform 10th Lecture
C# Language & .NET Platform 11th Lecture
C# Language & .NET Platform 9th Lecture
Parameter transmission
C Pointers Another ref:
Introduction to Pointers
Presentation transcript:

A simple function

1. Call by Value

1. Call by Value

2. Call by address

2. Call by address

Pointer Example : 1

Example of a simple Reference

Example of Reference in a function

3. Call by Reference

3. Call by Reference

2.1  References (or Aliases) (&) Recall that C/C++ use & to denote the address-of operator in an expression. C++ assigns an additional meaning to & in declaration to declare a reference variable. The meaning of symbol & is different in an expression and in a declaration. When it is used in an expression, & denotes the address-of operator, which returns the address of a variable, e.g., if number is an int variable, &number returns the address of the variable number (this has been described in the above section). Howeve, when & is used in a declaration (including function formal parameters), it is part of the type identifier and is used to declare a reference variable (or reference or alias or alternate name). It is used to provide another name, or another reference, or alias to an existing variable. The syntax is as follow:

References