Skip to main content

Student Database using Dynamic Memory Allocation in C++

Problem Statement:- Develop a program in C++ to create a database of student's information system containing the following information: Name, Roll number, Class, Division, Date of Birth, Blood group, Contact address, Telephone number, Driving license no. and other. Construct the database with suitable member functions. Make use of constructor, default constructor, copy constructor, destructor, static member functions, friend class, this pointer, inline code and dynamic memory allocation operators-new and delete as well as exception handling.

Note:- Scroll Horizonatally to see full line of code.

// Student DataBase Assignment
#include<iostream>
#include<string.h>
using namespace std;

class student{
    private:
        string name,roll_no,cls,div,dob,blood_group,contact_address,telephone,dl_no;
        static int count;
    public:
    // Default Constructor
    student(){
        cout<<"Default Constructor"<<endl;
        name="Name";
        roll_no="Roll No.";
        cls="Class";
        div="Division";
        dob="Date of Birth";
        blood_group="Blood group";
        contact_address="Contact Address";
        telephone="Telephone No.";
        dl_no="Driving Licence No.";
        count++;
    }
    // Parametrised Constructor
    student(string name,string roll_no,string cls,string div,string dob,string blood_group,
    string contact_address,string telephone,string dl_no){
        cout<<"Parametrised Constructor"<<endl;
        this->name=name;
        this->roll_no=roll_no;
        this->cls=cls;
        this->div=div;
        this->dob=dob;
        this->blood_group=blood_group;
        this->contact_address=contact_address;
        this->telephone=telephone;
        this->dl_no=dl_no;        
        count++;
    }
    // Copy Constructor
    student(student& s){
        cout<<"Copy Constructor"<<endl;
        name=s.name;
        roll_no=s.roll_no;
        cls=s.cls;
        div=s.div;
        dob=s.dob;
        blood_group=s.blood_group;
        contact_address=s.contact_address;
        telephone=s.telephone;
        dl_no=s.dl_no;
        count++;
    }
    
    // Friend Class
    friend class display;
      
    // Inline function
    void get_details()
    {
        
        cout<<"Enter the  student Details:"<<endl;
        cout<<"Name                       :";
        cin>>name;
        cout<<"Roll No.                   :";
        cin>>roll_no;
        cout<<"Class (FE/SE/TE/BE)        :";
        cin>>cls;
        cout<<"Division (e.g.1)           :";
        cin>>div;
        cout<<"Date of Birth (DD//MM/YYYY):";
        cin>>dob;
        cout<<"Blood Group (e.g.AB+)      :";
        cin>>blood_group;
        cout<<"Contact address            :";
        cin>>contact_address;
        cout<<"Telephone No.              :";
        cin>>telephone;
        cout<<"Driving Licence No.        :";
        cin>>dl_no;
        
    }

    static int getCount() {
         return count;
      }

    // Destructor 
    ~student(){
        cout<<"All objects are destructed!!! in the Destructor!!!!\n";
    }
};

class display{
    public:
    void show(student& s);
};

inline void display::show(student& s){
        cout<<"The student Details are as follows:"<<endl;
        cout<<"Name               :"<<s.name<<endl;
        cout<<"Roll No.           :"<<s.roll_no<<endl;
        cout<<"Class              :"<<s.cls<<endl;
        cout<<"Division           :"<<s.div<<endl;
        cout<<"Date of Birth      :"<<s.dob<<endl;
        cout<<"Blood Group        :"<<s.blood_group<<endl;
        cout<<"Contact address    :"<<s.contact_address<<endl;
        cout<<"Telephone No.      :"<<s.telephone<<endl;
        cout<<"Driving Licence No.:"<<s.dl_no<<endl;
}

int student::count=0;

int main(){
    display a;
    student s;
    cout<<"student s is:";a.show(s);
   
    student s1("Sanket","123456","SE","E","22/11/2003","O+","MUmbai","4561237890","DL456123");
    cout<<"student s1 is:";a.show(s1);
    
    student s2=s;
    cout<<"student s2 is:";a.show(s2);
    
    student s3=s1;
    cout<<"student s3 is:";a.show(s3);
    
    cout<<"How may students do you want to Add?:";
    int size;
    cin>>size;
    student *s4=new student[size];
        for(int i=0;i<size;i++){
        s4[i].get_details();
        }
    for(int i=0;i<size;i++){
        cout<<"student s4["<<i<<"]:"<<endl;
        a.show((s4[i]));
    }

    cout<<"The no. student in the datatbase are:"<<student::getCount()<<endl;
    delete[] s4;

    
    return 0;
}

Comments

Popular posts from this blog

Uninstalling AnyDesk from Ubuntu: A Step-by-Step Guide

If you're an Ubuntu user looking to remove AnyDesk from your system and reclaim valuable space, this straightforward guide will walk you through the uninstallation process with easy-to-follow steps. Step 1: Launch the Terminal To initiate the uninstallation process, open the Terminal on your Ubuntu system by simultaneously pressing "Ctrl + Alt + T." Step 2: Verify AnyDesk Installation Confirm that AnyDesk is installed on your system by typing the following command in the Terminal and pressing "Enter": dpkg -l | grep anydesk The relevant information will be displayed if AnyDesk is installed. Step 3: Uninstall AnyDesk Remove AnyDesk from your Ubuntu system using the following command in the Terminal: sudo apt-get remove anydesk Enter your user password when prompted (characters won't be visible as you type) and press "Enter" to authorize the uninstallation. Step 4: Confirm Unins...

SET THEORY USING LIST IN PYTHON

Problem Statement :- In second-year computer engineering class, group A student's play cricket, group B students play badminton and group C students play football.  Write a Python program using functions to compute the following:-     a) List of students who play both cricket and badminton     b) List of students who play either cricket or badminton or both     c) Number of students who play neither cricket nor badminton     d) Number of students who play cricket and football but not badminton. (Note- While realizing the group, duplicate entries should be avoided, Do not use SET built-in functions) Note :- Scroll horizontally to see the full line of code. def   Addelem ( A ,  a ):      for   i   in   range  ( a ):          elem = input ( "Enter the name of student:" )          if ( elem   ...

Implementations of Search Algorithms using Python | Linear Sequential Search | Sentinel Sequential Search | Binary Search | Fibonacci Search

  Problem Statement:-  a) Write a Python program to store roll numbers of student in array who attended training program in random order. Write function for searching whether particular student attended training program or not, using Linear search and Sentinel search. b) Write a Python program to store roll numbers of students array who attended training program in sorted order. Write function for searching whether particular student attended training program or not, using Binary search and Fibonacci search. Note:-  Scroll horizontally to see the full line of code. def linear_search ( a , target ):     for i in range ( len ( a )):         if ( a [ i ]== target ):             print ( "Roll no." , target , "is present at index" , i )             break     else :         print ( "Roll no." , target , "not found in list" ) def binary_search ( a , targ...

C++ Program for storing Appointments Schedule for day using Linked list | Display Free Slots | Book Appointment | Cancel Appointment | Sort Appointments

  Problem Statement: Write C++ program for storing appointment schedule for day. Appointments are booked randomly using linked list. Set start and end time and min and max duration for visit slot. Write Functions for-     A) Display free slots     B) Book appointments     C) Sort list based on time     D) Cancel appointment ( check validity, time bounds, availability )     E) Sort list base on time using pointer manipulation. Note: Scroll Horizontally to see the full line of code. #include < iostream > using namespace std ; class slot { public :     int startTime , endTime , min , max ;     bool status ;     slot * next ;     slot ( int start , int end , int min , int max )     {         startTime = start ;         endTime = end ;         this -> min = min ;         this ->...

Complete Guide: Uninstalling Steam from Ubuntu - Step-by-Step

Steam is widely favored among gamers for its seamless game distribution and vibrant community engagement. However, excessive game installations can burden your PC, leading to sluggish performance and potential system crashes. If you're facing such issues, a thorough uninstallation of Steam from your Ubuntu system might be the solution. Simply removing Steam using standard methods may leave residual files and directories on your device, potentially causing lingering issues. This comprehensive guide will walk you through the process of completely removing Steam from your Ubuntu system. Steps to Fully Uninstall Steam from Ubuntu: Before proceeding, ensure to back up any important data as uninstalling Steam will also remove all associated games, DLCs, and saved data. Follow these steps to uninstall Steam from Ubuntu: Step 1: Open the terminal by right-clicking or pressing “ctrl...