SlideShare ist ein Scribd-Unternehmen logo
1 von 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!

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 

Kürzlich hochgeladen (20)

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

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.

Hinweis der Redaktion

  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. 老子道德经:第一章 无名,天地之始;有名,万物之母。 故常无欲,以观其妙;常有欲,以观其徼。 此两者,同出而异名,同谓之玄。玄之又玄,众妙之门。 “ 无”可以用来表述天地浑沌未开之际的状况;而“有”,则是宇宙万物产生之本原的命名。 因此,要常从“无”中去观察领悟“道”的奥妙;要常从“有”中去观 察体会“道”的端倪。 无与有这两者,来源相同而名称相异,都可以称之为玄妙、深远。 它不是一般的玄妙、深奥,而是玄妙又玄妙、深远又深远,是宇宙天地万物之奥妙的总门 ( 从“有名”的奥妙到达无形的奥妙,“道”是洞悉一切奥妙变化的门径 ) 。