know yourselves. information, computer, 7 wonders, various.

Monday, November 6, 2017

C++ programming language part- 64 File Input and Output with abstract data types


File Input and Output with abstract data types

The following programs deal with file input and output using user-define classes. A class called bill is being used for this purpose.

Writing Objects

Program 46_5
            //file input/output
            #include
            class bill
            {  public:
                int bill_no;
                float bill_amt;
            };
            void main()
            { ofstream  bfil_1("bilfile.txt");     //object would be any name
               bill obj1;
               obj1.bill_no=1;
               obj1.bill_amt=125.56;
               bfil_1<







Reading Object

Program 46_6
//file input/output
            #include
            class bill
            {  public:
                int bill_no;
                float bill_amt;
    char bill_str[30];
            };   
            void main()
            {  ifstream bfil_2("bilfile.txt");
               bill obj2;
               bfil_2>>obj2.bill_no>>obj2.bill_amt>>obj2.bill_str;
               cout<<"number= "<
               cout<<"amount= "<
   cout<<" Name= "<


Writing and Reading object together


Program 46_7
{ ofstream  bfil_1("bilfile2.txt");     //object would be any name
               bill obj1;
               obj1.bill_no=1;
               obj1.bill_amt=125.56;
               bfil_1<
           
ifstream bfil_2("bilfile2.txt");
            bill obj2;
            bfil_2>>obj2.bill_no>>obj2.bill_amt;
            cout<<"number= "<
            cout<<"amount= "<

cout<<"Name = "<





জ্ঞানকোষ প্রকাশনী
৩৮/২-ক, বাংলাবাজার (২য় তলা), ঢাকা।
       ফোনঃ ৭১১৮৪৪৩, ৮১১২৪৪১, ৮৬২৩২৫১.         
                                                     
কলকাতায় পরিবেশক/প্রাপ্তিস্থান
রিতা ইন্টারন্যাশনাল
৩৬, পি.এন. ব্যানার্জি রোড, কলকাতা
ফোনঃ ২৫১৩৮৩৫৯, ৯৮৩০৪৩৯৬৭৯, +৯১৯৮৩০৪৩৯৬৭৯