C++ program to illustrate a Single Inheritance

SINGLE INHERITANCE

AIM:
A program to illustrate a single inheritance. We have a base class B and a derived class D. The class B contains one private data member, one public data member and three public member functions. The class D contains one private data member and two public member functions

ALGORITHAM:

• Start the process
• Invoke the base class B
• Invoke the derived class D using public derivation
• Get the input data
• Display the inputted data
• Call the derived classes member functions
o Assign a new value for base classes data member
• Display the outputs
• Stop the process

PROGRAM

#include<iostream.h>
#include<conio.h>
class B
{
int a;
public:
int b;
void get_ab();
int get_a();
void show_a();
};
class D: private B
{
int c;
public:
void mul();
void display();
};
void B::get_ab()
{
cout<<"Enter Values for a and b";
cin>>a>>b;
}
int B::get_a()
{
return a;
}
void B::show_a(){
			cout<<"a= "<<a<<"\n";
		}
void D::mul()
{
			get_ab();
			c=b*get_a();
       	}
void D:: display()
{
show_a();
cout<<"b= "<<b<<"\n";
cout<<"c= "<<c<<"\n\n";
}
void main()
{
			clrscr();
			D d;
			d.mul();
			d.display();
			d.mul();
			d.display();
			getch();
		}

OUTPUT

A=5
A=5
B=10
C=50

A=5
B=20
C=100

Editorial Team
Editorial Team

We are a group of young techies trying to provide the best study material for all Electronic and Computer science students. We are publishing Microcontroller projects, Basic Electronics, Digital Electronics, Computer projects and also c/c++, java programs.

53 thoughts on “C++ program to illustrate a Single Inheritance

  1. hi sir my name is ameen syd
    & i am B C S IV sem student in aurangabad (MH)

    PLEASE SIR GIVE ME A SIMPLE PROGRAME IN MY E mail ID
    THANK U SO MUCH

    PLZ YOUR GIADANCE IS MUST SIR

  2. In order to play around with this particular method, you can outsource some link constructing to your G+ page as well as try using automated link constructing software to
    get the work done.

  3. each time i useed to read smaller articles or reviews that
    as welol clear their motive, and tat is also happening with this piece of writing which I am
    reading here.

  4. Providing Microsoft Access training to your staff means your investment will
    not be short-lived as the knowledge that they gain can be beneficial for the
    company for years to come. One of the biggest problems I’ve always had with Microsoft Office is that it, like many things, becomes outdated.
    doc there are quite a few different extensions you can use (i.

  5. If you wish for to increase your familiarity just keep
    visiting this site and be updated with the most recent information posted here.

  6. Fantastic goods from you, man. I have understand your stuff previous to and you’re just too fantastic.

    I actually like what you’ve acquired here, really
    like what you are saying and the way in which you say it.
    You make it entertaining and you still care for to keep it sensible.
    I cant wait to read far more from you. This is actually a tremendous web site.

  7. Hi there this is kinda of off topic but I was wondering
    if blogs use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding knowledge so I wanted to get
    advice from someone with experience. Any help would be enormously
    appreciated!

  8. I don’t even know how I ended up here, but I thought this post
    was good. I don’t know who you are but certainly you’re going to
    a famous blogger if you are not already 😉 Cheers!

  9. Apart from the high-finish 15″ macbook pro, Apple also provides two 13″ types and a
    song 17″ device. Clear the PRAM (intel MacBooks only) Reboot your computer whenever holding down the command + option + p + r keys together.

  10. Hello!
    Does anyone contain the similar complications as i accomplish?
    Could not apparently any further gratify my personal companion from the sleeping quarters.
    Soon after having a few youngsters I have missing the particular baby-belly weight however I can not apparently re-tighten my own vagina.

    I can consistently accomplish other considerations for making your pet content inside the sleeping
    quarters mainly because vaginal sexual intercourse no longer excites your ex.
    Help! I’ve started considering merchandise and techniques to correct this kind of,
    may any person propose an excellent a single?

    Cheers!

  11. Not only this while installing with many exclusive amenities
    such as world class service. We can hardly know which luxury riad in marrakech medina
    species might be the equivalent social implications of driverless cars?

    Perform 10 repetitions in this manner and then switch to the left of
    where Gideon was calling out. Efforts spent
    in out-of-the-saddle sprinting are not wasted owing to
    the luxury riad in marrakech medina design using real-time geospatial data and guides.

  12. Andy Reid has the potential in his lineup to create a team that finds even more
    success than the Eagles of the last decade. Leonard Weaver – The guy had 19 touches last night for 70 yards.

    – At one point during the 2005 season, Donovan Mc – Nabb threw nine
    consecutive touchdown passes of distances of seven yards
    or less.

  13. Thanks for another wonderful post. The place else may just anybody get that type of information in such a perfect way of writing?

    I have a presentation subsequent week, and I’m on the look for such info.

  14. Thanks for one’s marvelous posting! I really enjoyed reading it, youu can be a great author.
    I will always bookmark your blog and will come back in thhe foreseeable future.
    I want to encourage you to ultimately continue your great job,
    have a nice weekend!

  15. First off I want to say awesome blog! I had a quick
    question in which I’d like to ask if you don’t mind.
    I was curious to know how you center yourself and clear your mind prior to writing.
    I have had a tough time clearing my mind in getting my ideas out there.

    I do enjoy writing but it just seems like the first
    10 to 15 minutes tend to be lost just trying to figure out how to begin. Any ideas or
    hints? Appreciate it!

  16. Back in the 1930’sPsychiatrist were at odds abc with the problem of gun homicides.
    Although transition-age youths with mental illness is,” Would that be OK with you? Medical treatment may only be comfortable pushing for more coverage for mental health clinicians at the jail, and by the next day!

  17. Good point. You could intend to review my newest short article
    too. I don’t want to sound to pompous but I make sure you will certainly
    discover it appealing.
    Best,
    Allan

  18. I was recommended this website by my cousin. I’m not sure whether this post is written by
    him as no one else know such detailed about my trouble.
    You are amazing! Thanks!

  19. Hello There. I discovered your weblog the usage of msn. That is a
    very well written article. I’ll make sure to bookmark it and come
    back to read extra of your useful info. Thanks for
    the post. I’ll definitely return.

  20. It represents the water element, and is used to enhance wealth
    and career luck. Let’s talk about several these gemstones as are used by the psychic to
    improve their psychic ability. The sixth chakra is known as the third eye chakra and it is situated in the middle of the forehead connectingthe eyebrows.

  21. We have now since they have been born – both boys, and we use clippers as nicely, and it’s nice.

    We do not burden some poor barber with our squirmy, lively boys, and we save money.
    As on me this advise is not going to save a lot of money for you or they’re so simple, that solely lazy or stupid
    people don’t observe them.

  22. Hello There. I found your weblog the usage of msn. That is a really
    well written article. I will make sure to bookmark it and come
    back to read more of your helpful information. Thanks for
    the post. I’ll definitely return.

  23. Użytkowania okazał się materiału do malowania stał się roli.
    Styropianu. Które mają za dom, ogrodzeń
    czy architekci szczególnie polecany do tej metody jest wypalany temperaturze około stopni.
    Także na największe ciężary fundamenty, wtedy będzie cieszył oczy i formy,
    dzięki odpowiedniej produkcji. Wytworzone z.

  24. Thanks for sharing your thoughts. I really appreciate your efforts and I am
    waiting for your next post thank you once again.

  25. Greate post. Keepp posting such kind of information on your blog.
    Im really impressed by it.
    Hello there, You’ve done a great job. I will certainly digg it and in mmy opinion recommend to my
    friends. I’m confident they will be benefited from this
    website.

  26. u have wrote a wrong program .u have to big mistake in the program .u have written this program from msbte techmax book .you liar .and this is nor getting any output

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in