Class and Structure. 2 Structure Declare using the keyword struct purpose is to group data Default visibility mode is public A struct doesn't have a constructor.

Slides:



Advertisements
Similar presentations
Operator overloading redefine the operations of operators
Advertisements

Constructors and Destructors. Constructor Constructor—what’s this? Constructor—what’s this? method used for initializing objects (of certain class) method.
Object-Oriented programming in C++ Classes as units of encapsulation Information Hiding Inheritance polymorphism and dynamic dispatching Storage management.
Contents o Introduction o Characteristics of Constructor. o Types of constructor. - Default Constructor - Parameterized Constructor - Copy Constructor.
I NHERITANCE Chapter 7 Department of CSE, BUET 1.
C++ Classes & Data Abstraction
CSCI 3328 Object Oriented Programming in C# Chapter 9: Classes and Objects: A Deeper Look 1 Xiang Lian The University of Texas – Pan American Edinburg,
Inheritance. 2 The process of deriving new class from the existing one is called inheritance Then the old class is called base class and the new class.
OOP Using Classes - I. Structures vs. Classes C-style structures –No “interface” If implementation changes, all programs using that struct must change.
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
C++ data types. Structs vs. Classes C++ Classes.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Constructors A constructor is a method that creates an object in Java. It does not return anything and it is not void. It’s only purpose is to create an.
Operator Overloading Customised behaviour of operators Unit - 06.
CSE 333 – SECTION 4. Overview Pointers vs. references Const Classes, constructors, new, delete, etc. More operator overloading.
1 Classes- Inheritance Multiple Inheritance It is possible to derive a new class from more than one base class. This is called Multiple Inheritance. Under.
Inheritance and Class Hierarchies Ellen Walker CPSC 201 Data Structures Hiram College.
C# D1 CSC 298 Elements of C# code (part 2). C# D2 Writing a class (or a struct)  Similarly to Java or C++  Fields: to hold the class data  Methods:
CS 11 C++ track: lecture 4 Today: More on memory management the stack and the heap inline functions structs vs. classes.
CS212: Object Oriented Analysis and Design Lecture 15: Inheritance in C++ -II.
Chapter 10 Classes and Objects: A Deeper Look Visual C# 2010 for Programmers © by Pearson Education, Inc. All Rights Reserved.
1 Inheritance. 2 Why use inheritance?  The most important aspect of inheritance is that it expresses a relationship between the new class and the base.
ECE122 Feb. 22, Any question on Vehicle sample code?
INHERITANCE IN C++ Amit Saxena PGT(CS) KV Rangapahar Cantt. (Nagaland)
Classes In C++ 1. What is a class Can make a new type in C++ by declaring a class. A class is an expanded concept of a data structure: instead of holding.
 Classes in c++ Presentation Topic  A collection of objects with same properties and functions is known as class. A class is used to define the characteristics.
Classes. Constructor A constructor is a special method whose purpose is to construct and initialize objects. Constructor name must be the same as the.
Inheritance Objectives: Creating new classes from existing classes The protected modifier Creating class hierarchies Abstract classes Indirect visibility.
© 2007 Lawrenceville Press Slide 1 Chapter 8 Objects  A variable of a data type that is a class. Also called an instance of a class.  Stores data  Can.
Static. 2 Objectives Introduce static keyword –examine syntax –describe common uses.
Csi2172 class 5 Midterm: June 12. constructor Special method used to create objects of the class Never has a return type. Is called automatically upon.
06E-1 oop C++ Addendum: Inheritance and Encapsulation C++ Addendum: Inheritance and Encapsulation uProtected members uInheritance Type uPublic Inheritance.
Encapsulation, Inheritance, Composition. Class Methods Can be either void or return Can have parameters or not Must be static Should be public Know how.
1 Mr. Muhammad Hanif Lecturer Information Technology MBBS Campus Dadu University of SIndh.
Classes in C++ And comparison to Java CS-1030 Dr. Mark L. Hornick.
Introduction to C# By: Abir Ghattas Michel Barakat.
1 Introduction to Object Oriented Programming Chapter 10.
Inheritance in C++ Bryce Boe 2012/08/28 CS32, Summer 2012 B.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 7: Introduction to Object- Oriented Programming in Python – Exercises Xiang Lian The University of.
Chapter 2 Objects and Classes
Procedural and Object-Oriented Programming
Classes C++ representation of an object
Static data members Constructors and Destructors
2.7 Inheritance Types of inheritance
Object-Oriented Programming (OOP) Lecture No. 45
Class A { public : Int x; A()
Object-Oriented Programming
Structs versus Classes
Chapter 5 Classes.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
group work #hifiTeam
OOP’S Concepts in C#.Net
Can perform actions and provide communication
Can perform actions and provide communication
Conditional Statements
Introduction of Programming
Object-Oriented Programming (OOP) Lecture No. 22
Java Programming Language
NAME 436.
Classes C++ representation of an object
Object oriented programming (OOP) Lecture No. 6
Types of Computer Languages
CS 201(Introduction To Programming)
CS148 Introduction to Programming II
C++ data types.
Objects as Function Arguments
Chapter 11 Classes.
Constructors & Destructors
Chapter 5 Classes.
Virtual base, constructor & destructor
Presentation transcript:

Class and Structure

2 Structure Declare using the keyword struct purpose is to group data Default visibility mode is public A struct doesn't have a constructor or destructor Cannot support overloaded operators. Cannot use C++-specific features such as inheritance and member functions. A structure couldn't be null like a class.

3 Class Declare using the keyword class A class should be used for grouping data and methods that operate on that data The class default access type is private Classes have a public and private members The default mode for inheritance is private. classes are used to encapsulate data and the functions Class support constructors and destructors Class support operator overloading & function Overloading Class can be declare al null

4 Class Vs Structure Members of a class are private by default and members of struct are public by default class Test { int x; // x is private }; void main() { Test t;// class boject t.x = 20; // compiler error // because x is private } struct Test { int x; // x is public }; void main() { Test t; t.x = 20; // works fine because x is public }