Professional Documents
Culture Documents
Copy Oc++f Public and Private
Copy Oc++f Public and Private
Copy Oc++f Public and Private
GC University Faisalabad
Topic
Access specifier is the keyword used for defining the scope of the member of class. There are two important access specifier in c++.
Private Public
Private
The private data and function can be accessed within the class
Only member of the same class can access the private data
It cant be accessed by functions outside the class Private access specifier is for internal use only.
Private
Data is important
The private data and function can be accessed within the class
It cant be accessed by functions outside the class Private access specifier is for internal use only.
Data
In capsulation
Public
Inside the member of the class
Public
Syntax
Access specifier
Topic
If Structure
If Structure
If statement Is a decision-making statement. It is the simplest form of selection constructs. it is used to execute or skip a statement or simply checking a statement
Using if/else
The if/else structure is sometimes called a two-way selection structure. Using if/else, one block of code is executed if the control expression is true. The else portion of the structure is executed if the control expression is false.
True or False
Condition
true
false
statement
True or False
Confusing = and = =
Dont confuse the meaning of = in Math with its meaning in C++. The symbol = means assigning a value to an identifier, and not that two objects or expressions are equal in C++. The symbol = = means equality in a comparison in C++. Side effects are caused if we confuse the two operators.
15