Code Competitions

Coding competition

Saturday, 15 June 2013

program to use derived class pointer to point to base class by using explicit type casting

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class book
{
    private:
    char title[15];
    float price;
    int pon;
    public:
    void getdata()
    {
        cout<<"\nenter the title of book ";
        cin>>title;
        cout<<"\nprice of book";
        cin>>price;
        cout<<" no. of pages ";
        cin>>pon;
    }
    void display()
    {
        cout<<"\ntitle "<<title;
        cout<<" total pages "<<pon;
        cout<<" price "<<price;

    }
};
class sdetail:public book
{
    private:
    char agency[20];
    int id;
    public:
    void getdata()
    {
        cout<<" agency name ";
        gets(agency);
        cout<<" registration number ";
        cin>>id;

    }
    void display()
    {
        //book::display();
        cout<<" agency name "<<agency;
        cout<<" reg. no. "<<id;

    }
};
void main()
{
    clrscr();
    class sdetail *p,*q,y;
    class book x;
    p=q;
    p=(sdetail *) &x;
    p->getdata();
    p->display();
    getch();
}

23 comments:

  1. Bandar Judi Terpercaya dan Teraman di Indonesia. BOLAVITA

    ReplyDelete
  2. Banyak bonus yang kami berikan gabung langsung di sin ya ==> AGENS128

    ReplyDelete
  3. please try to comment in english, for my understanding, so that I can help you better.

    ReplyDelete


  4. Home

    Visitors

    History

    Monitor

    Settings

    Team
    0 requests


    Visitors
    INCOMING
    ASSIGNED
    CLICKED
    SERVED
    TRIGGERED
    ACTIVE
    IDLE
    #44570760
    1
    88CSN1158550Baik
    Actions



    88CSN1158550
    Current chatPast chats (3)
    Detected language
    Indonesian
    TranslateDismiss
    11:36 PM
    88CSN1158550 has joined.
    88CSN115855011:36 PM
    Maaf bosku untuk deposit sya tf ke rekening mana ya
    11:36 PM
    Chikka Aprillia has joined.
    88CSN115855011:36 PM
    Cimb niaga
    Bca sedang ofline ya
    Chikka Aprillia11:36 PM
    ya bosku untuk cimb sedang gangguan ya bosku
    88CSN115855011:36 PM
    Lalu sya deposit ke mana ya bosku
    Chikka Aprillia11:37 PM
    ke bni kita saja ya bosku
    BNI
    Nama Rek : FANDI TIRTA SAPUTRA
    Nomor Rek : 755184501
    Berikut ini rekening tujuan BNI kami ya bosku ^^
    88CSN115855011:37 PM
    Baik
    Emoji
    RatingAttach
    88CSN1158550
    Add email
    Add phone number
    Add visitor notes
    Add chat tags
    40
    Past visits
    3
    Past chats
    2 mins
    Time on site
    Visitor path
    Direct traffic
    88CSN | Situs Slot Terpercaya | Agen Terpercaya |
    Location
    Jakarta, Jakarta, Indonesia
    Browser
    Chrome 74.0.3729.112
    Platform
    Android 8.1.0
    Device
    Samsung SM-J730G
    IP address
    114.124.233.153
    Hostname
    -
    User agent
    Mozilla/5.0 (Linux; Android 8.1.0; SM-J730G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.112 Mobile Safari/537.36

    ReplyDelete