SlideShare una empresa de Scribd logo
1 de 31
Set Theory in C++   Andrew Zhuang [email_address] Aug.7, 2008
Outline ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
the Concepts of a class in C++ and a Set in the Set Theory ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Commonality of a Set vs. Public Members of a Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Commonality of a Set vs. Public Members of a Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Commonality of a Set vs. Public Members of a Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Commonality of a Set vs. Public Members of a Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Commonality of a Set vs. Public Members of a Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Commonality of a Set vs. Public Members of a Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Commonality of a Set vs. Public Members of a Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Commonality of a Set vs. Public Members of a Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Commonality of a Set vs. Public Members of a Class ,[object Object],[object Object],[object Object],[object Object],[object Object]
Commonality of a Set vs. Public Members of a Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Commonality of a Set vs. Public Members of a Class ,[object Object],[object Object],[object Object],[object Object],[object Object]
Commonality of a Set vs. Public Members of a Class ,[object Object],[object Object],[object Object],[object Object],[object Object]
Commonality of a Set vs. Public Members of a Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Commonality of a Set vs. Public Members of a Class ,[object Object],[object Object],[object Object],[object Object],[object Object]
Empty Set vs. an Abstract Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Single Element Set vs. Singleton ,[object Object],[object Object],class Singleton { public: static Singleton* Instance(); protected: Singleton(); private: static Singleton* _instance; }; ,[object Object],Singleton* Singleton::_instance = 0; Singleton* Singleton::Instance() { if (_instance == 0) { _instance = new Singleton; } return _instance; }
the  Partition of a Set vs. Single Inheritance of a Class class A0 { }; class A1: public A0 { }; class A2: public A1 { }; ,[object Object],[object Object],[object Object],[object Object]
the  Partition of a Set vs. Single Inheritance of a Class ,[object Object],class A_0 { }; class A_1 : public A_0 { public: move();  }; class A_2 : public A_2 { public: unmove(); }; ,[object Object],[object Object]
the  Partition of a Set vs. Single Inheritance of a Class ,[object Object],class A_0 { }; class A_1 : public A_0 { }; class A_2 : public A_2 { }; ,[object Object],[object Object]
Multiple Inheritances vs. Intersection of Multiple Sets class A { … }; class B { … }; class C: public A, public B { … }; ,[object Object],[object Object],[object Object]
Multiple Inheritances vs. Intersection of Multiple Sets ,[object Object],class window  { … }; class window_with_menu: public virtual window { … }; class window_with_border: public virtual windw { … }; class window_with_menu_and_border:  public window_with_menu, public window_with_border { … }; A:  window B:  window_with_menu , C:  window_with_border D:  window_with_menu_and_border
Multiple Inheritances vs. Intersection of Multiple Sets ,[object Object],[object Object],[object Object],[object Object],[object Object]
Modulization vs.Union of Sets ,[object Object],[object Object]
Single Inheritance from an Abstract Class ,[object Object],[object Object],class Shape {  public: virtual void rotate(int) = 0;  virtual void draw() = 0;  virtual bool is_closed() = 0; // … }; class Circle : public Shape { public:  void rotate(int) { } void draw(); bool is_closed() { return true;} Circle(Point p, int r); private: Point Center; int radius;  }; class Polygon : public shape {  public: bool is_closed() { return true;} // … draw and rotate not overriden… }; ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Single Inheritance from an Abstract Class ,[object Object],[object Object],template <class T> class Stack { T* v; int max_size; int top; public; class Underflow { }; class Overflow() { }; Stack(int s); // constructor ~Stack();  // destructor void push(T); T pop(); }; typedef Stack<char>  Stack_char; typedef Stack<dog *>  Stack_pdog; typedef Stack<list<int>> Stack_li ,[object Object],[object Object],[object Object]
Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
References ,[object Object],[object Object],[object Object],[object Object]
Thank You!

Más contenido relacionado

La actualidad más candente

Friends function and_classes
Friends function and_classesFriends function and_classes
Friends function and_classes
asadsardar
 
#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance
Hadziq Fabroyir
 
Inheritance
InheritanceInheritance
Inheritance
Tech_MX
 

La actualidad más candente (20)

Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
E4
E4E4
E4
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend class
 
Inheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingInheritance, Object Oriented Programming
Inheritance, Object Oriented Programming
 
Friend Function
Friend FunctionFriend Function
Friend Function
 
inheritance c++
inheritance c++inheritance c++
inheritance c++
 
Friends function and_classes
Friends function and_classesFriends function and_classes
Friends function and_classes
 
Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.
 
#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
Inheritance Inheritance
Inheritance
 
Inheritance in oops
Inheritance in oopsInheritance in oops
Inheritance in oops
 
Inheritance
InheritanceInheritance
Inheritance
 
Single inheritance
Single inheritanceSingle inheritance
Single inheritance
 
Advanced c#
Advanced c#Advanced c#
Advanced c#
 
C++ Notes
C++ NotesC++ Notes
C++ Notes
 
inheritance
inheritanceinheritance
inheritance
 

Similar a Set Theory In C++

OOP Week 3 Lecture 2.pptx
OOP Week 3 Lecture 2.pptxOOP Week 3 Lecture 2.pptx
OOP Week 3 Lecture 2.pptx
whoiam36
 
Inheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ optInheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ opt
deepakskb2013
 
Class&objects
Class&objectsClass&objects
Class&objects
harivng
 
Chapter18 class-and-objects
Chapter18 class-and-objectsChapter18 class-and-objects
Chapter18 class-and-objects
Deepak Singh
 

Similar a Set Theory In C++ (20)

cse l 5.pptx
cse l 5.pptxcse l 5.pptx
cse l 5.pptx
 
inheritence
inheritenceinheritence
inheritence
 
11 Inheritance.ppt
11 Inheritance.ppt11 Inheritance.ppt
11 Inheritance.ppt
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
inheritance
inheritanceinheritance
inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
OOP Week 3 Lecture 2.pptx
OOP Week 3 Lecture 2.pptxOOP Week 3 Lecture 2.pptx
OOP Week 3 Lecture 2.pptx
 
Inheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ optInheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ opt
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Class&objects
Class&objectsClass&objects
Class&objects
 
chapter-7-classes-and-objects.pdf
chapter-7-classes-and-objects.pdfchapter-7-classes-and-objects.pdf
chapter-7-classes-and-objects.pdf
 
Chapter18 class-and-objects
Chapter18 class-and-objectsChapter18 class-and-objects
Chapter18 class-and-objects
 
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCECLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
 
chapter-10-inheritance.pdf
chapter-10-inheritance.pdfchapter-10-inheritance.pdf
chapter-10-inheritance.pdf
 
Inheritance_with_its_types_single_multi_hybrid
Inheritance_with_its_types_single_multi_hybridInheritance_with_its_types_single_multi_hybrid
Inheritance_with_its_types_single_multi_hybrid
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
 
4 Classes & Objects
4 Classes & Objects4 Classes & Objects
4 Classes & Objects
 

Último

Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Último (20)

FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 

Set Theory In C++

  • 1. Set Theory in C++ Andrew Zhuang [email_address] Aug.7, 2008
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.

Notas del editor

  1. The first method of enumeration is not applicable in C++, and the second method defining commonality of the elements is used to declare and define a class in C++.
  2. A class is not discerned or classified by its private or protected members, but by its public ones which are visible.
  3. This basically restates the rules for member access (§15.3) [1]. We choose access for bases in the same way as for members. [1]
  4. Question: When should a composition class or a derived class be used? Answer: Composition is used to describe the relationship that “A is part of B” while the single inheritance is used to represents the relationship that “A is a kind (or subset) of B” . And the multiple inheritances represent the relationship that “A is a kind of B in the same time A is a kind C” or “A is the intersection of set B and set C”.
  5. By default, C++ matches a function call with the correct function definition at compile time. This is called static binding . You can specify that the compiler match a function call with the correct function definition at run time; this is called dynamic binding .
  6. By default, C++ matches a function call with the correct function definition at compile time. This is called static binding . You can specify that the compiler match a function call with the correct function definition at run time; this is called dynamic binding .
  7. Actually we can change Singleton a little bit to permit it to have some number of elements.
  8. For example, we can think A0 represents flower , A1 represents rose , and A2 represents red rose .
  9. For example, A_0 is integer , A1 is odd number , and A_2 is even numbe r. When A_1 has 2 more public functions compared to its base class A_0, then we can defined the below complete subclasses from A_0. class A_1: public A_0 { public: move(); draw(); }; class A_2: public A_0 { public: unmove(); draw(); }; class A_3: public A_0 { public: move(); undraw(); }; class A_4: public A_0 { public: unmove(); undraw(); };
  10. A_0 can be an abstract class or not.
  11. Actually we can pick up the two arbitrary classes and then derive a new class from them in C++, however we need to think of the semantics of what we are doing. For example, 1) the class of TCP process can be derived from the two classes: Process and TCP ; 2) some guy is a scientist and musician . class C: public A, protected B { … }; Only the friends of B, the derived classes of B and the friends of the derived classes of B think C is a kind of A and B. class C: public A, private B { … }; Only the friends of B think C is a kind of A and B.
  12. From above figure, we can understand why class window is declared as the virtual base of class window_with_menu and class window_with_border.
  13. 老子道德经:第一章 无名,天地之始;有名,万物之母。 故常无欲,以观其妙;常有欲,以观其徼。 此两者,同出而异名,同谓之玄。玄之又玄,众妙之门。 “ 无”可以用来表述天地浑沌未开之际的状况;而“有”,则是宇宙万物产生之本原的命名。 因此,要常从“无”中去观察领悟“道”的奥妙;要常从“有”中去观 察体会“道”的端倪。 无与有这两者,来源相同而名称相异,都可以称之为玄妙、深远。 它不是一般的玄妙、深奥,而是玄妙又玄妙、深远又深远,是宇宙天地万物之奥妙的总门 ( 从“有名”的奥妙到达无形的奥妙,“道”是洞悉一切奥妙变化的门径 ) 。