Object Oriented Programming Notes(C++)

Revision en7, by abdude824, 2021-08-19 20:57:41

We will be discussing major topics here and actually difficult ones. You must know basic OOPs.

Introduction

C structures Vs C++ Classes
General structure of classes
Visibility labels(Public, private, protected
Some terms and their meaning
For CP lovers, here is class based implementation of segment trees and Euler tours, representing inheritance as well
Memory allocation of member variables and functions accross objects

Static Data members

As we saw in memory allocation diagram, copies of member variables are made for different objects. But if we want a common variable for all objects of class? For example in an employee class, we need to find the number of employees at a specific time. We can do it using a global variable but that variable can interfere in the whole working of program. We can use a static data member. Static members are initialized to 0 and one important thing to note is that type and scope of static variable is defined outside the class. This is because they are not of every object but are unique to a class.

Sample Code for static data members

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en29 English abdude824 2022-08-10 12:46:07 2 (published)
en28 English abdude824 2022-08-10 12:45:45 64 Reverted to en26
en27 English abdude824 2022-07-21 14:19:23 64 (saved to drafts)
en26 English abdude824 2021-09-20 10:08:43 950
en25 English abdude824 2021-08-25 12:30:52 97
en24 English abdude824 2021-08-22 17:51:00 369
en23 English abdude824 2021-08-21 09:49:20 38 Tiny change: ' type.\n\n\n## Inh' -> ' type.\n\n**Type Conversion**\n\nTo be updated\n\n## Inh' (published)
en22 English abdude824 2021-08-20 21:07:00 480
en21 English abdude824 2021-08-20 19:56:08 1363
en20 English abdude824 2021-08-20 19:41:14 467
en19 English abdude824 2021-08-20 19:34:03 1012 Tiny change: ' form a+$i%b">\n\n</s' -> ' form a+$i$b">\n\n</s'
en18 English abdude824 2021-08-20 17:44:31 2 Tiny change: ' would be suing this t' -> ' would be using this t'
en17 English abdude824 2021-08-20 15:20:16 126
en16 English abdude824 2021-08-20 13:19:28 16
en15 English abdude824 2021-08-20 13:17:47 762
en14 English abdude824 2021-08-20 12:51:38 764
en13 English abdude824 2021-08-20 12:36:39 103
en12 English abdude824 2021-08-20 12:29:44 1758
en11 English abdude824 2021-08-20 11:57:34 2049
en10 English abdude824 2021-08-20 11:43:02 130
en9 English abdude824 2021-08-19 22:32:45 907
en8 English abdude824 2021-08-19 21:26:19 2653
en7 English abdude824 2021-08-19 20:57:41 1054
en6 English abdude824 2021-08-19 15:24:19 3
en5 English abdude824 2021-08-17 21:33:53 894 Tiny change: '/articles/n5kflb4dv5c2koi41uk2.png)\n</' -> '/articles/qnvv0uasstduy2zueqo2.png)\n</'
en4 English abdude824 2021-08-17 10:59:06 4 Tiny change: 'ask/1138\n~~~~~\n#' -> 'ask/1138\n\n~~~~~\n#'
en3 English abdude824 2021-08-17 10:58:45 5290
en2 English abdude824 2021-08-17 10:37:59 559
en1 English abdude824 2021-08-17 10:31:10 1201 Initial revision (saved to drafts)