DBMS | Practicals

No SQL DESCRIPTION
1 SELECT DATA RETRIEVAL
2 INSERT
UPDATE
DELETE
DATA MANIPULATION LANGUAGE (DML)
3 CREATE
ALTER
DROP
RENAME
TRANCATE
DATA DEFINATION LANGUAGE (DDL)
4 COMMIT
ROLLBACK
SAVEPOINT
RENAME
TRANCATE
TRANSICTION CONTROL LANGUAGE (TCL)
5 GRAND
REVOKE
DATA CONTROL LANGUAGE (DCL)
No LABs PRACTICALS
1 LAB-1 CREATE TABLE
Syntax:
CREATE TABLE schema_name.table_name (
column_1 data_type column_constraint,
column_2 data_type column_constraint,
...
table_constraint
);
Example:
create table DEPARTMENT (
deptno number,
deptname varchar2(50) not null,
location varchar2(50),
constraint pk_department primary key (deptno)
);

create table EMPLOYEE (
empno number,
name varchar2(50) not null,
jobtitle varchar2(50),
manager number,
hiredate date,
salary number(7,2),
commission number(7,2),
deptno number,
constraint pk_employee primary key (empno),
constraint fk_employee_deptno foreign key (deptno)
references DEPARTMENT (deptno)
);
2 LAB-2 ALTER TABLE
It is used to add, MODIFY, or drop columns.

Syntax for ADD:

ALTER TABLE table_name ADD (column datatype,column datatype....);
Example:
Suppose we want to ADD new column (location) in existing table
ALTER TABLE department ADD location varchar2(50);

Syntax for MODIFY:

ALTER TABLE table_name MODIFY (column datatype,column datatype....);
Example:
Suppose we wants to change/modify the size of column location from 50 to 20
ALTER TABLE deptartment MODIFY location varchar(20);

Syntax for DROP:

ALTER TABLE table_name DROP COLUMN column_name ;
Example:
Suppose we wants to remove the column location from department table.
ALTER TABLE dept DROP COLUMN location

Syntax for RENAME COLUMN NAME:

ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name ;
Example:
Suppose we wants to rename/ change the name of column.
ALTER TABLE dept RENAME COLUMN location to dept_loc

Syntax for RENAME table NAME:

RENAME table_name TO new_table_name;
Example:
Suppose we wants to rename/ change the name of TABLE.
RENAME dept TO department;
3 LAB-3 DROP TABLE
Dorp command will drop/remove the structure of table
Syntax: DROP TABLE table_name;
Example: DROP TABLE department;
4 LAB-4 TRUNCATE
We can not ROLLBACK trancated table.It is parmanent deleted from storage.
Syntax: TRUNCATE table table_name;
Example: TRUNCATE table emp;
5 LAB-5 Working with Constraints
Following Constraints are used in SQL
Type of COnstraints:
  • NOT NULL
  • UNIQUE
  • PRIMARY KEY
  • FOREIGN KEY
  • CHECK
Examples: Different Way to define Constraints

1. CREATE TABLE EMPLOYEE(
EID NUMBER(6) PRIMARY KEY,
ENAME VARCHAR2(50) NOT NULL,
SAL NUMBER(9) CHECK(SAL<>>0),
AGE NUMBER(2) CHECK(AGE>18)
)

2. CREATE TABLE EMPLOYEE(
EID NUMBER(6) CONSTRAINT EMP_EID PRIMARY KEY,
ENAME VARCHAR2(50) CONSTRAINT EMP_ENAME NOT NULL,
SAL NUMBER(9) CONSTRAINT EMP_SAL CHECK(SAL<>0),
AGE NUMBER(2) CONSTRAINT EMP_AGE CHECK(AGE>18)
)

3. CREATE TABLE EMPLOYEE(
EID NUMBER(6),
ENAME VARCHAR2(50) NOT NULL,
SAL NUMBER(9),
AGE NUMBER(2),
CONSTRAINT EMP_EID_PK PRIMARY KEY (EID),
CONSTRAINT EMP_SAL_CK CHECK(SAL<>0),
CONSTRAINT EMP_AGE_CK CHECK(AGE>18)

)

4. DEFINE FOREIGN KEY CONTRAINT
CREATE TABLE DEPARTMENT(
DID NUMBER(6) PRIMARY KEY,
DNAME VARCHAR2(50) NOT NULL
)
CREATE TABLE EMPLOYEE(
EID NUMBER(6) PRIMARY KEY,
ENAME VARCHAR2(50) NOT NULL,
DID NUMBER(6) REFERENCES DEPARTMRNT(DID)
)

OR

CREATE TABLE DEPARTMENT(
DID NUMBER(6) PRIMARY KEY,
DNAME VARCHAR2(50) NOT NULL
)
CREATE TABLE EMPLOYEE(
EID NUMBER(6) PRIMARY KEY,
ENAME VARCHAR2(50) NOT NULL,
DID NUMBER(6) CONSTRAINT DID_FK REFERENCES DEPARTMRNT(DID)
)

OR

CREATE TABLE DEPARTMENT(
DID NUMBER(6) PRIMARY KEY,
DNAME VARCHAR2(50) NOT NULL
)
CREATE TABLE EMPLOYEE(
EID NUMBER(6) PRIMARY KEY,
ENAME VARCHAR2(50) NOT NULL,
DID NUMBER(6),
CONSTRAINT EMP_DID_FK FOREIGN KEY (DID) REFERENCES DEPARTMRNT(DID)
)
4 LAB-4 RENAME
INFO
Syntax:
Example:

Sql Concept using Oracle

CONTENTS DESCRIPTION
  • SELECT
DATA RETRIEVAL
  • INSERT
  • UPDATE
  • DELETE
DATA MANIPULATION LANGUAGE (DML)
  • CREATE
  • ALTER
  • DROP
  • RENAME
  • TRUNCATE
DATA DEFINATION LANGUAGE (DDL)
  • COMMIT
  • ROLLBACK
  • SAVEPOINT
TRANSACTION CONTROL LANGUAGE (TCL)
  • GRANT
  • REVOKE
DATA CONTROL LANGUAGE (DCL)

SQL DESCRIPTION
  • */{DISTINCT} COLUMN
For retrive data All/Not repeted
  • ARITHMETIC OPERATIONS(* , / ,+, -)
Mathematical Operations
  • COLUMN ALLIASES (BY USING AS / ””)
Define another name of column
  • CONCATENATION (||)
Concate more than one string or columns
  • DESC / DESCRIBE
Show the schema of any table or view
WHERE CLAUSE
  • COMPARISION OPERATORS
    (= , <, <=, >, >=, <>)
Use of comparision operators
  • BETWEEN ….. AND Condition
Use of between and condition
  • IN CONDITION
Use of IN Condition
  • LIKE CONDITION
Use of LIKE Condition
  • NULL CONDITION
Use of NULL Condition
  • LOGICAL CONDITION (AND, OR, NOT)
Use of logical Operators
  • ORDER BY CLAUSE (ASC / DESC)
Show data in ASC/DESC Order

LNCT University Btech CSE VIII Semester - Syllabus


LNCT University, Bhopal

Internet of Things (CS-801-A)/(AL-801-A)

COURSE OUTCOMES:

After Completing the course student should be able to
CO1 Understand internet of things and its hardware and software components
CO2 Design interface I/O devices, sensors & communication modules.
CO3 Analyse data from various sources in real-time
CO4 Monitor data and devices with remote control.
CO5 Develop real life IOT based projects.
Course contents:

Unit –I

INTRODUCTION TO WEB ENGINEERING

IoT definition, Characteristics, IoT conceptual and architectural framework, Components of IoT ecosystems, Physical and logical design of IoT, IoT enablers, Modern day IoT applications, M2M communications, IoT vs M2M, IoT vs WoT, IoT reference architecture, IoT Network configurations, IoT LAN, IoT WAN, IoT Node, IoT Gateway, IoT Proxy, Review of Basic Microcontrollers and interfacing.

Unit –II

Define Sensor, Basic components and challenges of a sensor node, Sensor features, Sensor resolution; Sensor classes: Analog, Digital, Scalar, Vector Sensors; Sensor Types, bias, drift, Hysteresis error, quantization error; Actuator; Actuator types: Hydraulic, Pneumatic, electrical, thermal/magnetic, mechanical actuators, soft actuators

Unit –III

Basics of IoT Networking, IoT Components, Functional components of IoT, IoT service Oriented architecture, IoT challenges, 6LowPAN, IEEE 802.15.4, ZigBee and its types, RFID Features, RFID working principle and applications, NFC (Near Field communication), Bluetooth, Wireless Sensor Networks and its Applications.

Unit –IV

MQTT, MQTT methods and components, MQTT communication, topics and applications, SMQTT, CoAP, CoAP message types, CoAP Request-Response model, XMPP, AMQP features and components, AMQP frame types.

Unit –V

IoT Platforms, Arduino, Raspberry Pi Board, Other IoT Platforms; Data Analytics for IoT, Cloud for IoT, Cloud storage models & communication APIs, Attacks in IoT system, Vulnerability analysis in IoT, IoT case studies: Smart Home, Smart framing etc.

References

  1. Vijay Madisetti, Arshdeep Bahga, “IoT, A Hands on Approach”, University Press.
  2. Dr. SRN Reddy, RachitThukral and Manasi Mishra, “Introduction to Internet of Things: A practical Approach”, ETI Labs.
  3. Pethuru Raj and Anupama C. Raman, “The Internet of Things: Enabling Technologies, Platforms, and Use Cases”, CRC Press.
  4. Jeeva Jose, “Internet of Things”, Khanna Publishing House, Delhi.
  5. Adrian McEwen, “Designing the Internet of Things”, Wiley.
  6. Raj Kamal, “Internet of Things: Architecture and Design”, McGraw Hill.
  7. CunoPfister, “Getting Started with the Internet of Things”, O Reilly Media


LNCT University, Bhopal

Block Chain (CS-801-B/Al-801-B)

COURSE OUTCOMES:

After Completing the course student should be able to
CO1 Understand concepts and terminology of blockchain.
CO2 Utilize block chain concepts for crypto currency application.
CO3 Classify block chain and compare the types for design issues.
CO4 Illustrate the block chain application development with simulator.
CO5 Understand block chain enabled trade.
Course contents:

UNIT I: OVERVIEW OF BLOCK CHAIN

Public Ledgers, Bit coin, Smart Contracts, Block in a Block chain, Transactions, Crypto currency to Block chain, Distributed Consensus, Public vs Private Block chain, Permissioned Model of Block chain, Overview of Security aspects of Block chain; Basic Crypto Primitives: Cryptographic Hash Function, Properties of a hash function, Hash pointer and Merkle tree, Digital Signature, Public Key Cryptography.

UNIT II: UNDERSTANDING BLOCK CHAIN WITH CRYPTO CURRENCY

Bit coin and Block chain: Creation of coins, Payments and double spending, Bit coin Scripts, Bit coin P2P Network, Transaction in Bit coin Network, Block Mining, Block propagation and block relay. Working with Consensus in Bit coin: Distributed consensus in open environments, Consensus in a Bitcoin network, Proof of Work (PoW) – basic introduction, Hash Cash PoW, Bit coin PoW, Attacks on PoW and the monopoly problem, Proof of Stake, Proof of Burn and Proof of Elapsed Time, The life of a Bitcoin Miner, Mining Difficulty, Mining Pool.

UNIT III: UNDERSTANDING BLOCK CHAIN FOR ENTERPRISES

Permissioned Block chain: Permissioned model and use cases, Design issues for Permissioned block chains, Execute contracts, State machine replication, Overview of Consensus models for permissioned block chain- Distributed consensus in closed environment, Paxos, RAFT Consensus, Byzantine general problem, Byzantine fault tolerant system, Lamport-Shostak-Pease BFT Algorithm, BFT over Asynchronous systems.

UNIT IV: ENTERPRISE APPLICATION OF BLOCK CHAIN

Cross border payments, Know Your Customer (KYC), Food Security, Mortgage over Block chain, Block chain enabled Trade, We Trade – Trade Finance Network, Supply Chain Financing, and Identity on Block chai.

UNIT V: BLOCK CHAIN APPLICATION DEVELOPMENT

Hyperledger Fabric- Architecture, Identities and Policies, Membership and Access Control, Channels, Transaction Validation, Writing smart contract using Hyperledger Fabric, Writing smart contract using Ethereum, Overview of Ripple and Corda.

References

  1. Melanie Swan, “Block Chain: Blueprint for a New Economy”, O‟Reilly, 2015.
  2. . Josh Thompsons, “Block Chain: The Block Chain for Beginners- Guide to Block chain Technology and Leveraging Block Chain Programming”.
  3. Daniel Drescher, “Block Chain Basics”, Apress; 1stedition, 2017.
  4. Anshul Kaushik, “Block Chain and Crypto Currencies”, Khanna Publishing House, Delhi.
  5. . Imran Bashir, “Mastering Block Chain: Distributed Ledger Technology, Decentralization and Smart Contracts Explained”, Packt Publishing.
  6. Salman Baset, Luc Desrosiers, Nitin Gaur, Petr Novotny, Anthony O‟Dowd, Venkatraman Ramakrishna, “Hands-On Block Chain with Hyperledger: Building Decentralized Applications with Hyperledger Fabric and Composer”, Import, 2018.


Download AI Handwritten Notes

BTech CSE III Semester
SNO TOPICS DOWNLOAD
1
    General Issues and Overview of AI
  • The AI problems
  • What is an AI technique
  • Characteristics of AI applications
    Introduction to LISP Programming
  • Syntax
  • Numeric functions
  • Basic list manipulation functions
  • Predicates
  • Conditionals
  • Input output
  • local variables
  • Iteraction and recursion
  • Iteraction and recursion
  • Arrays
2 Introduction of Control Strategy
3
    Control Strategy ....
  • DFS(Depth First Search)
4
    Control Strategy ....
  • BFS(Breadth First Search)
5 Hueristic Search
6 Hill Climbing Algorithms
  • Simple Hill Climbing
  • Steepest-Ascent Hill Climbing
  • 7 Best First Search (BFS)
    8 A Star(A*) Algorithm
    9 Problem Reduction Algorithm
    10 AO Star (AO*) Algorithm
    11 Constraint Satisfaction Algorithm
    12 Mean End Analysis Algorithm
    13 Clouser Form
    14 Conceptual Dependency
    15 Frames
    16 Knowledge Representation
    17 Predicate Logic
    18 Resolution In Pridicate Logic
    19 Resolution In Preposition Logic
    20 Script
    21 Sementic Net
    22 Unification Algorithm
    # Topic-#

    Model Paper-III | BCE




    B.Tech CSE II Semester Model Paper
    Basic Computer Engineering  (BT-203) 
    Time:3 Hours Max Marks:70
    Sno. Questions Marks

    SECTION-1
    Note: Attempt all question
    a What do you understand hierarchical directory structure. 2
    b What is the need of operating system? 2
    c What do you understand by compiler and interpreter?  2
    d What are object oriented concepts? 2
    e How we define class and object in C++. 2
    SECTION-2
    Note:Attempt Any Five
    a Discuss about the hierarchy of computer memory. 4
    b Write down the goal of OSI model in computer network. 4
    c What do you understand by anti-spyware software? 4
    d What is the use of directory in operating system? 4

    e What is database query language. 4

    f Why traditional file system is not reliable. 4

    g What is networking ? Write their goal. 4
    SECTION-3
    Note: Attempt all question
    a Write a program to overload pre and post increment operator in c++.
    10
    OR
    What do you understand by data communication.

    b Difference between OSI model and TCP/IP model. 10
    OR
    What do you understand by default and parameterized constructor.

    c Explain data independency with the help of diagram. 10
    OR
    What do you understand by ER-model.
    d
    Explain about the application of cloud computing.
    10
    OR
    What do you understand by architecture of cloud computing? 

    More Papers

    Model Paper-II | BCE




    B.Tech CSE II Semester Model Paper
    Basic Computer Engineering  (BT-203) 
    Time:3 Hours Max Marks:70
    Sno. Questions Marks

    SECTION-1
    Note: Attempt all question
    a What do you understand by class and object. 2
    b Explain the use of file and folders in system. 2
    c Explain the memory hierarchy of a system.  2
    d What do you understand by compiler and assembler? 2
    e What do you understand by tokens in c++. 2
    SECTION-2
    Note:Attempt Any Five
    a Write down the type of software in operating system. 4
    b Explain about logic bomb and email spooling. 4
    c Explain the organization of Computer. 4
    d Write down the properties of C++. 4

    e What are tokens in C++ ? 4

    f What do you understand by dbms ? How it is more secure than traditional file system. 4

    g What is inter networking ? 4
    SECTION-3
    Note: Attempt all question
    a What do you understand by three level schema of dbms.
    10
    OR
    Explain all layers of OSI model in detail.

    b What is operator overloading explain with proper example.List out the operator that can not be overloaded. 10
    OR
    What do you understand by constructor and their type?

    c Write short note on  (a) Data dictionary (b) Internet 10
    OR
    What do you understand by Trojans and Worms
    d
    What do you understand by e-commerce and www.
    10
    OR
    What do you understand by cloud infrastructure ? 

    More Papers

    Model Paper-I | BCE




    B.Tech CSE II Semester Model Paper
    Basic Computer Engineering  (BT-203) 
    Time:3 Hours Max Marks:70
    Sno. Questions Marks

    SECTION-1
    Note: Attempt all question
    a Define computer.classify it. 2
    b What do you understand by booting process. 2
    c What do you understand by system software and utility software. 2
    d What do you understand by memory.. 2
    e Write down the functionality of CPU. 2
    SECTION-2
    Note:Attempt Any Five
    a What do you understand by software concept. 4
    b What is operator precedence? Write precedence of arithmetic operators 4
    c Explain the organization of Computer. 4
    d Write down the difference between C and C++. 4

    e What are C character sets ? What are tokens ? 4

    f What do you understand by type casting ? 4

    g What is computer network ? 4
    SECTION-3
    Note: Attempt all question
    a What do you understand by computer memory.classify it in detail.
    10
    OR
    Explain all layers of TCP/IP model in detail.

    b Write a program contain person as a base class and teacher and student as a derived class with some basic data.like (name,age,contact,address,subject,course, etc) 10
    OR
    Define a function? Explain two categories/types of argument passing techniques, with proper programs in C.

    c What are good computer security habits 10
    OR
    What do you understand by Virus, Malware
    d
    Explain (if, if-else, nested if-else, cascaded if else) in C language with syntax and example.
    10
    OR
    What is cloud computing ? 

    More Papers

    Extended Features of ER Diagram in DBMS

    Let we understand why this extended feature is needed. We know ER model is used to represent any database in pictorial view so that we can easily understand all about data but it is convenient if the data is not big or complex. But when the data become more complex than than we need to extend some feature in ER model.
    For the improvement of existing ER model three new feature are added such as
    1. Specialization
    2. Generalization
    3. Aggregation

    Specialization

    An entity set may include sub grouping of entities or we can say that broken down into sub-entities that are distinct in some way from other entities in the set.A subset of entities with in entity set may have attribute that are not shared by all the entity in entity set.It is a top-down approach based on the specific attribute of the entity type with in given entity type.
    Consider an entity set person with attribute Name,Age,Address,contact. Now a person may be further classified as one of the following.
    1. TEACHER
    2. STUDENT
    Each of these person is described by a set of attribute that include all the attribute of entity set person plus possible additional attributes for example Teacher and student entities may be describe further by the attribute such as teacher-id,salary and student-id respectively. The process of designating sub grouping within a entity set is called specialization. The specialization of person according to whether they are teacher or student.
    By using specialization we reduce redundancy fro example here a PERSON is sub grouping into two other entity set TEACHER and STUDENT. a PERSON contain its personal details as a attribute if the PERSON is a TEACHER than the personal detail of TEACHER is also the attribute of TEACHER.But in the case of specialization we have no need to repeat the personal detail of TEACHER entity set because TEACHER is a person and a personal detail of PERSON is given in PERSON entity set. In this way by using specialization redundancy will reduce.In specialization we create more than one entity set for a single entity.

    Generalization

    Generalization is a bottom-up approach in which multiple entity set combined into a higher level entity set on the basis of common features.The database designer may have first identify a TEACHER entity set with attribute TEACHER-NAME,AGE,CONTACT,ADDRESS,TEACHER-ID,SALARY,DESIG. and STUDENT entity set with the attribute NAME,AGE,CONTACT,ADDRESS,STUDENT-ID,COURSE.
    There are some similarity between both entity set with respect to attribute.These common type of attribute can be expressed by generalization which show relationship between higher level entity set and one or more lower level entity set.
    In this example the higher level entity set is PERSON and lower level entity set are TEACHER and STUDENT.Higher level entity set is a super class and lower level entity set is sub class such as PERSON supper class and TEACHER and STUDENT are sub class.
    Generalization proceed from the recognizance that a number of entity set share some common feature such as personal details.On the basis of common features the generalization combine these entity set into a single higher level entity set. Generalization show the similarity among higher level entity set and hide the differences.It is also take care that shared attribute are not repeated.

    Constraints on Generalization

    1. User Define or Condition Define
      Condition Define:We distribute the entity after checking one condition.
      for example assume highet level entity set student has attribute set student has attribute marks and the lower level entity are pass & fail.
      we valuate the student after checking condition.Suppose condition is if marks is greater than 40 than student is pass and if marks is less than 40 than student is fail.
      User Define:In user define there is no checking condition such as,
    2. Total or Partial
      Total:Each higher level entity belong to a lower level entity.
      here Suppose we have three student records such as x,y,z
      x41
      y45
      z31

      student x & y are pass and student z become fail.
      Partial:Some higher level entity may not belongs to lower level entiry such as
      Suppose we have marks of the student
      x41
      yWH (with haled)
      z45

      here x will pass
      z also pass
      But in the case of y its marks is not derived because it is with haled
      So this y which is one of higher level entity is not belong to lower level entities.
    3. Disjoint or Overlapped
      Disjoint:In disjoint constraint higher entity set are not belong to more than one entity set.
      No student are both fail and pass, so it is disjoint constraint because student is either pass or fail.It belong to only one lower level entity.
      Overlapped:In overlapped constraint some higher level entity belongs to more than one lower level entity such as
      xTeacher
      yTeacher & Student both
      zStudent

      here the high level entity are person which is (x, y, z)
      x-> belongs to teacher
      z-> belong to student
      But y-> belong to both teacher and student so the y (high level entity) belongs to more than one lower level entity (Teacher, Student)
      So we say this is overlapped.

    Aggregation

    One of the major problem of ER-model is that it is not possible to express the relationship among relationship. If we say in ER-diagram we can not have line from relationship diagonal box to another diagonal box.
    So for solving this problem, we use the concept of aggregation.
    For example
    We have two entity set Doctor & Patient such as

    If we want to relate new entity nurse with doctor-patient relationship than
    One way is that nurse relate to both doctor and patient separately such as

    But in this case redundancy is increasing.
    So the another approach is aggregation.
    In this approach first we make a abstract entity set than we relate with new entity set such as Nurse such as

    Inheritance | C++

    Inheritance in C++


    Re-usability is one of the important feature in OOPs that we can achieve by inheritance. It is a concept of derived class and Base class.
    It is the mechanism of deriving new class from old class is called inheritance.
    Here the old class is called derived class and new class is called derived class.
    The derived class inherit some or all the properties of the base class.A class can also inherit the properties of more than one class or more than one level.

    Derived Class


    Derived class is define by specifying its relationship with the base class in addition to its own details. The general form of defining derived class is
    class derived class-name : visibility mode base class-name
    {
    members of derived class;
    }

    Here the (:) colon indicate that derived class-name is derived from its base class-name. The visibility mode is optional and if present may be either private or public. The default visibility mode is private visibility mode specifies whether the feature of base class are privately or publically derived.

    On the basis of accessibility


    There are three type of accessibility
    1. Private
    2. Public
    3. Protected

    Example

    class base
    {
    members of base
    };
    CASE I:
    class derived-1 : public base
    {
    members of derived-1 + Public member of base and protected member of base
    };
    CASE II:
    class derived-2 : protected base
    {
    members of derived-2 + public and protected member of base
    };
    CASE III:
    class derived-3 : private base
    {
    members of derived-3 + public and protected member of base
    };

    Let we discuss about the cases


    Case I : When base class is inherited publicaly by derived 1 class than.


    • public member of base class are inherited as a public.
    • private member of base class are not accessable.
    • protected member of base class are inherited as a protected.

    Case II : When base class is inherited as a protected by derived 2 class than.


    • public member of base class are inherited as a protected.
    • private member of base class are not inherited.
    • protected member of base class are inherited as a protected.
    so in derived 2 class members will be:
    public :
    int a2;
    protected :
    int c2 , x , z;
    int b2;

    Case III : When base class is inherited as a private by derived 3 class than.


    • public member of base class are inherited as a private.
    • private member of base class are not inherited.
    • protected member of base class are inherited as a private.
    so in derived 3 class members will be:
    public :
    int a3;
    protected :
    int c3;
    int b2,x,z;

    Type of inheritance


    1. Based on structure of inheritance
    2. Based on accessibility of inheritance

    Based on structure of inheritance


    1. Simple inheritance or single inheritance
    2. Multilevel inheritance
    3. Hierarchical inheritance
    4. Multiple inheritance
    5. Hybrid inheritance

    Single inheritance


    A derived class with only one base class is called single inheritance

    Example


    Copy Code
    #include <iostream>

    using namespace std;
    class person //base class
    {
        string name;
        string add;

    public:
    person()
    {
        name='\0';
        add='\0';
    }
    person(string n)
    {
        name=n;
        add='\0';
    }
    person(string n,string a)
    {
        name=n;
        add=a;
    }
    void read()
    {
        cout<<"Enter name:";
        cin>>name;
        cout<<"Enter address:";
        cin>>add;
    }
    void print()
    {
        cout<<"Name="<<name<<"\n";
        cout<<"Address="<<add<<"\n";
    }
    };

    class stud:public person
    {
        string scno;
        int marks;
        public:
        stud()
        {
            scno='\0';
            marks=0;
        }
        stud(string s)
        {
            scno=s;
            marks=0;
        }
        stud(string s,int m)
        {
            scno=s;
            marks=m;
        }
        void read()
        {
            person::read();
            cout<<"Enter scno:";
            cin>>scno;
            cout<<"Enter marks:";
            cin>>marks;
        }
        void print()
        {
            person::print();
            cout<<"SCNO="<<scno<<"\n";
            cout<<"Marks:"<<marks;
        }
    };

    int main()
    {
        stud st;
        st.read();
        st.print();

        return 0;
    }

    Output

    Enter name:shailu
    Enter address:bhopal
    Enter scno:23
    Enter marks:60
    Name=shailu
    Address=bhopal
    SCNO=23
    Marks:60

    Multilevel inheritance


    The mechanism of deriving a class from another derived class is called multilevel inheritance

    Hierarchical inheritance


    One class may be inherited by more than one derived class is called hierarchical inheritance.

    Multiple inheritance


    One derived class with several base class is called multiple inheritance.

    Hybrid inheritance


    Combination of one or more above inheritance is called hybrid inheritance.
    code

    Type Conversion | C++

    Type Conversion in C++


    There are type of situation arise in data conversion between uncompatable type.
    1. Type I : Conversion from built in type (BDT-basic data type) to built in type (BDT-basic data type)
    2. Type II : Conversion from built in type (BDT-basic data type) to class type (UDT-user define data type)
    3. Type III : Conversion from class type (UDT-user define data type) to built in type (BDT-basic data type)
    4. Type IV : Conversion from class type (UDT-user define data type) to class type (UDT-user define data type)

    Type I : Conversion from built in type (BDT-basic data type) to built in type (BDT-basic data type)


    This type of conversion is done automatically.

    Type II : Conversion from built in type (BDT-basic data type) to class type (UDT-user define data type)


    Here if we want to convert BDT to UDT than some additional overloaded conversion function takes place in destination class. such as:
     
    operator int()  
        {              
           return(a); 
        }

    Example

    Copy Code
    #include <iostream>

    using namespace std;
    class source
    {
        int a;
        public:
        source()
        {
            a=0;
        }
        source(int x)
        {
            a=x;
        }
        
        operator int() // for type conversion obj s1= int r; in main here int is converted into source  
        {              // for BDT to UDT 
           return(a); 
        }
        
        ~source(){ }
    };


    int main()
    {
       source s1; 
       int r=10;
       s1=r; 
       cout<<s1;
       return 0;
    }

    Output:

    10


    Type III : Conversion from class type (UDT-user define data type) to built in type (BDT-basic data type)


    Here if we want to convert BDT to UDT than some additional overloaded conversion function takes place in source class. such as:

    operator int()  
        {              
           return(a); 
        }

    Example

    Copy Code
    #include <iostream>

    using namespace std;
    class source
    {
        int a;
        public:
        source()
        {
            a=0;
        }
        source(int x)
        {
            a=x;
        }
        
        operator int() // for type conversion  int r= s1 (object) in main here source is converted into int
        {              // for UDT to BDT conversion
           return(a); 
        }
        int geta()
        {
            return(a);
        }
        
          ~source(){ }
    };


    int main()
    {
      source s1;
      int r=s1;
      cout<<s1;
      return 0;
    }

    Output:

    0

    Type IV : Conversion from class type (UDT-user define data type) to class type (UDT-user define data type)


    Case I: For d = s

    If source is the source class and dest is the destination class than
    We can write d = s in main() after adding some conversion function in source class and overload conversion function in destination class such as
    In Source class function is
     
    int geta()
        {
            return(a);
        }

    In destination class overload function is
     
    dest (source obj)
        {
            p=obj.geta();
        }
    Note:This overloaded conversion function is used when we want to access the private data member of source class indirectly.
    Indirectly means we can not access private data member of source class. So we access conversion function of source class which is define in source class.
    It must be noted that those class which define first is called source class like source and dest class is define after source class so it is a destination class.

    Example

    Copy Code
    #include <iostream>
    using namespace std;

    class source
    {
        int a;
        public:
        source()
        {
            a=0;
        }
        source(int x)
        {
            a=x;
        }
            
        int geta()
        {
            return(a);
        }
         
        ~source(){ }
    };

    class dest
    {
        int p;
        public:
        dest()
        {
            p=0;
        }
        dest(int x)
        {
            p=x;
        }
        operator int()  
        {              
           return(p); 
        }
        
        dest (source obj)
        {
            p=obj.geta();
        }
        
        ~dest(){ }
    };


    int main()
    {
      source s1;
      dest d1;
      d1=s1; // convert from s1 (source type) to d1(dest type)
      cout<<d1;
      return 0;
    }

    Output:

    0

    Case II: For s = d

    If the source class is dest and destination class is source than conversion function in source class and overload conversion function in destination class will be
    In Source class function is
     
    int getp()
        {
            return(p);
        }

    In destination class overload function is
     
    dest (source obj)
        {
            a=obj.getp();
        }

    Output:

    0

    Example

    Copy Code
    #include <iostream>
    using namespace std;


    class dest
    {
        int p;
        public:
        dest()
        {
            p=0;
        }
        dest(int x)
        {
            p=x;
        }
        
        int getp()
        {
            return(p);
        } 
        
        ~dest(){ }
    };

    class source
    {
        int a;
        public:
        source()
        {
            a=0;
        }
        source(int x)
        {
            a=x;
        }
        operator int()
        {
            return(a);
        }
        
        source (dest obj)
        {
            a=obj.getp();
        }
        ~source(){ }
    };

    int main()
    {
      source s1;
      dest d1;
      s1=d1; // convert from d1 (source type) to s1(dest type)
      cout<<s1;
      return 0;
    }

    Output:

    0