C++ Info
C++ Info
used.
c lang was devloped by bell labs on 1970. major opreating system in c language is
UNIX.
c and c++ is top-down stuctured programming.
In each function there is single exit or single entry.
Disadvantages of stucture programing -----------
repeated things , lengthy , more space occupied in memory,slow work.
inline functtion is used when function contaion program of 2-3 lines small code. it
was fast function .
if we want to move code fast we use inline function.
-----------------------------------------
Lec26---------------------------------
CLASS: it include both data members(arrays,stucture,pointeer,data type) and
functions.
instance OF CLASS ARE CALLED OBJECT.
private(only use in class ), protected(use within class or child class), public
(use in whole program).
constructor is a special function , it has not written type , it has same name as
class , it intiliaze class data member , it was automatically called ,
it was called auto when class obeject was called .
-------------------------------------------------
Lec27-----------------------------------------------------
destructor is a special function , it has not written type , it has same name as
class with delta ~ sign in start (eg ~Student) ,
it dsestroy class from RAM when class is completely executed , it was
automatically called ,it was called auto when class obeject was called
-------------------------------------------------
Lec28-----------------------------------------------------
Diff btw classes and stucture is visibility stucture are public.
Memory allocate in c is by heap function or remove by free , memory allocate in c++
is by free store function or remove by delete.
-------------------------------------------------
Lec30----------------------------------------------------
refernce variable are mostly used in function calls.
-------------------------------------------------
Lec31----------------------------------------------------
to connenct two strings with opreater overload we use strcat() funvtion with
string.h header file.
there are two types of opreater to overload 1.Unary 2.Binary.
-------------------------------------------------
Lec35----------------------------------------------------
There are two types of streams input and output streams. Every stream has assosiat
source and destination.
Input is source and output is destination.
cin.get (vriable name)(for single char),cin.getline(var,size)(for
statement),cin.read(var,size)(jitna size likho wo complete krna he na zada jo na
kam ho size),
cout.write().
-------------------------------------------------
Lec36----------------------------------------------------
cin.eof() it will return the state end of a file.
cin.bad() any error in program
cin.clear() clear the failed state of the stream.
MANIPULATORS are like something whuch can be inserted into stream, effecting change
in the behaviour.
two types non parameterized(used without argument) and parameterized.
-------------------------------------------------
Lec38--------------------------------------------------
USER DEFINED MAIPULATORS: predefined manipulators created by user.eg:ostream
&mainpulatar_name(ostream & os)
STATIC KEYWORD: when static keyword is used varaible or data members or functions
can not be modified again.it is allocated for lifetime program.
static function are called directly by class name. static variable are inialized
only once. eg : static int i;
-------------------------------------------------
Lec39--------------------------------------------------
REFERENCE:reference can be considered as a special type of pointer as it also
contains the memoory address.
CALL BY VALUE: if vakue is given in parameters of a function.
CALL BY REFERENCE: when pass the reference or varaiable as a parameter of a
function.
DYNAMIC MEMORY ALLOCATION: allocate new memory using new keyword and release memory
using delete keyword.
declare a variable : int a; | DECLARATION WITH INTIALIZATION: if we declare
variable and then we assign it some value within same line code eg :int a=10;
COPY CONSTRUCTOR: the values of data members of that temporary object is same as
the orignal object .
RULES FOR DYNAMIC MEMORY ALLOCATION: 1.we made constructor in our class 2. we
assign values 3. we destruct values
-------------------------------------------------
Lec40--------------------------------------------------
OBJECT AS A CLASS MEMBER :when one class contains object of other class.
STUCTURE AS A CLASS MEMBER : any stucture object as a class member
CLASSES INSIDE THE CLASSES: classes defined within otheer classes also called
nested classes.
-------------------------------------------------
Lec41--------------------------------------------------
TEMPLETE IS A GENERIC DATA TYPE. it has TWo types 1.Function templates 2. Class
templates.
OVERLOADING TEMPLATE FUNCTION: the multiples function having same name but have
different arguments is called overloading template.
-------------------------------------------------
Lec43--------------------------------------------------