Develop an object oriented program in C++ to create a database of student information.

#include<iostream>
#include<cstring>
using namespace std;

class Studdb1
{
private:
    long mo_no;
    string lno;
   
   
   
public:
    int roll_no,cls;
    string add,bldgrp,dob;
    char div;
    //void end();
    Studdb1()    
    {
        roll_no=0;
        dob="null";
        mo_no=0000;
        lno="null";
        cls=0;
        add="null";
        bldgrp="null";
        div='\0';
    }
   
    Studdb1(int roll_no,int cls,char div,string dob,string bldgrp,string add,long mo_no,string lno)
    {
        this->roll_no=roll_no;
        this->cls=cls;
        this->div=div;       
        this->dob=dob;
        this->bldgrp=bldgrp;
        this->add=add;
        this->mo_no=mo_no;
        this->lno=lno;
    }

    Studdb1(Studdb1 &s)
    {
        roll_no=s.roll_no;
        cls=s.cls;
        div=s.div;       
        dob=s.dob;
        bldgrp=s.bldgrp;
        add=s.add;
        mo_no=s.mo_no;
        lno=s.lno;
    }
   
    ~Studdb1()
    {
        cout<<"\n Memory destroyed...";
    }
   
   
    friend class Studf;
};


static inline void start()
    {
        static string str="GCOEARA...";
        cout<<"\n"<<str;
    }   

class Studf
{   
    public:

    void display(Studdb1 &a)
    {
        cout<<a.roll_no<<"\t"<<a.cls<<"\t"<<a.div<<"\t"<<a.dob<<"\t"<<a.bldgrp<<"\t"<<a.add<<"\t"<<a.mo_no<<"\t"<<a.lno;
       
    }

       
};
   
int main()
{
start();
   
    cout<<"\n Roll_no \t Class \t Div \t Dob \t bldgrp \t address \t mobile_no \t license_no \n";
    Studdb1 *s1=new Studdb1();
   
    Studf *sf=new Studf();
    //(*sf).display(*s1);
   
    Studdb1 *s2=new Studdb1(1,3,'a',"09-08-1997","B+","New Sangvi",9096337179,"123psw");
    (*sf).display(*s2);
    cout<<"\n";
    Studdb1 *s3=new Studdb1(*s2);
    (*sf).display(*s3);
    //delete s1;
    delete s2;
    delete s3;
   

}

-------------------------------------------------------------------------

Output

[student@localhost Pratiksha]$ g++ Studdb.cpp
[student@localhost Pratiksha]$ ./a.out

GCOEARA...
 Roll_no      Class      Div      Dob      bldgrp      address      mobile_no      license_no
1    3    a    09-08-1997    B+    New Sangvi    9096337989    123psw
1    3    a    09-08-1997    B+    New Sangvi    9096337687    123psw
 Memory destroyed...
 Memory destroyed...[student@localhost Pratiksha]$ gedit Studdb.cpp

Comments

Popular posts from this blog

Priority Scheduling Algorithm Java Program.

Implement a class CppArray which is identical to a one-dimensional C++ array (i.e., the index set is a set of consecutive integers starting at 0) except for the following : 1. It performs range checking. 2.It allows one to be assigned to another array through the use of assignment operator. 3.It supports a function that returns the size of the array.

Implement UNIX system calls like ps, fork, join, exec family, and wait for process management (use shell script/ Java/ C programming).