NESTED CLASS. Apa itu nested class ? Nested class is a class defined inside a class, that can be used within the scope of the class in which it is defined.

Slides:



Advertisements
Similar presentations
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 6 Repetition Statements.
Advertisements

Classes & Objects INTRODUCTION : This chapter introduces classes ; explains data hiding, abstraction & encapsulation and shows how a class implements these.
Complete Structure class Date {class Date { private :private : // private data and functions// private data and functions public :public : // public data.
Chapter 5 Inheritance. Objectives Introduction, effects, and benefits of inheritance Base class and derived class objects Base class and derived class.
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Copyright © 2002 Pearson Education, Inc. Slide 1.
For(int i = 1; i
Programming In C++ Spring Semester 2013 Practice 2 Programming In C++, Practice By Umer Rana.
Pass by Value. COMP104 Pass by Value / Slide 2 Passing Parameters by Value * A function returns a single result (assuming the function is not a void function)
Inheritance (2).
Class Scope class Student { private: string id; string firstName, lastName; float gpa; public: void Read() { cin >> id >> firstName >> lastName >> gpa;
1 CSC241: Object Oriented Programming Lecture No 21.
Review of Inheritance. 2 Several Levels of Inheritance Base Class B Derived class D Derived class D1.
1 Chapter 11 Introducing the Class Pages ( )
Structure.
Revision.
Operator Overloading. C++ 2 Outline  General technique  Overloading of the assignment operator  Overloading the increment and decrement operators.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 102 Computer Programming II (Lab:
Chapter 8. Operator Overloading Operator overloading gives the opportunity to redefine C++ Operator overloading refers to redefine C++ operators such.
EC-241 Object-Oriented Programming
Chapter 8 Scope, Lifetime and More on Functions. Definitions Scope –The region of program code where it is legal to reference (use) an identifier Three.
Inheritance zThe mechanism by which one class can inherit the properties of another. zIt allows a hierarchy of classes to be built, moving from the most.
Student Data Score First Name Last Name ID GPA DOB Phone... How to store student data in our programs? 1.
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
C++ Classes & Data Abstraction
1 Class Vehicle #include #define N 10../.. 2 Class Vehicle class vehicle { public: float speed; char colour[N+1]; char make[N+1];
Union, bitfield, typedef, enum union nama_u{ }; union nama_u{ struct nama_s byte; }; enum{ }; Tipedef var BYTE.
Les pointeurs 1. 00A0 00A1 00A2 00A3 00A4 00A5 00A6 00A7 00A8 00A9 00AA 00AB 00AC 00AD 00AE 00AF 00B0 2 Code du programme BSSTas void main(){ node exemple(0);
AB 11 22 33 44 55 66 77 88 99 10  20  19  18  17  16  15  14  13  12  11  21  22  23  24  25  26  27  28.
PASSING PARAMETERS 1. 2 Parameter Passing (by Value) Parameters Formal Parameters – parameters listed in the header of the function Variables used within.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
Computer Science 1620 Multi-Dimensional Arrays. we used arrays to store a set of data of the same type e.g. store the assignment grades for a particular.
1 CS 192 Lecture 5 Winter 2003 December 10-11, 2003 Dr. Shafay Shamail.
CSCI 171 Presentation 4. Execution of a C Program Execution starts in main( ) Top down style –sequential flow Unrealistic to expect sequence in more complicated.
Recap: Interfaces A class is a logical abstraction, but an object has physical existence. access-specifier can be: public: Allow functions or data to be.
1 OOP - An Introduction ISQS 6337 John R. Durrett.
Lecture 4 Function example. Example1 int max (int a, int b) { int c; if (a > b) c = a; else c = b; return (c); } void main ( ) {int x, y; cin>>x>>y; cout.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Introduction to Object Oriented Programming (OOP) Object Oriented programming is method of programming.
Introduction to Programming Lecture 40. Class Class is a user defined data type.
Friend Function. 2 Any data which is declared private inside a class is not accessible from outside the class. A non-member function cannot have an access.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Classes Sujana Jyothi C++ Workshop Day 2. A class in C++ is an encapsulation of data members and functions that manipulate the data. A class is a mechanism.
PZ01DX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ01DX - Overview of C and C++ Programming Language.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
1 Compiler directive: #define, usage 1 #include using namespace std; #define TAX //double TAX=0.08; #define LAST_NAME "Li" #define FIRST_NAME "Dennis"
01/05/100 1 Loops/Iteration Used to repeat an action Must have a STOP condition Three flavors - for, while, do/while.
Introduction to C++ programming Recap- session 1 Structure of C++ program Keywords Operators – Arithmetic – Relational – Logical Data types Classes and.
Access Functions and Friend Functions
Class and Objects UNIT II.
#define #include<iostream> using namespace std; #define GO
Intro to Programming Week # 6 Repetition Structure Lecture # 10
Lecture 4-7 Classes and Objects
Object Oriented Programming Language (OOP)
Ambiguity Resolution in Inheritance
HYBRID INHERITANCE : AMBIGUITY REMOVAL
Variables and Their scope
Repetition Control Structure
By Muhammad Waris Zargar
CS150 Introduction to Computer Science 1
Introduction to Programming
Midterm Thursday, in class.
class PrintOnetoTen { public static void main(String args[]) {
Observing how the machine acts
Alternate Version of STARTING OUT WITH C++ 4th Edition
STATIC DATA MEMBER & MEMBER FUNCTIONS
Object-Oriented Programming (OOP) Lecture No. 44
Review of Function Overloading
STORAGE CLASS.
Introduction to Programming
CS150 Introduction to Computer Science 1
Presentation transcript:

NESTED CLASS

Apa itu nested class ? Nested class is a class defined inside a class, that can be used within the scope of the class in which it is defined. In C++ nested classes are not given importance because of the strong and flexible usage of inheritance. Its objects are accessed using "Nest::Display". (sumber:

Contoh Nested Class C++ class Nest { public: class Display { private: int s; public: void sum( int a, int b) { s =a+b; } void show( ) { cout << "\nSum of a and b is:: " << s;} }; void main() { Nest::Display x; x.sum(12, 10); x.show(); }