1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Encapsulation, Inheritance and Polymorphism????

Discussion in 'Software' started by Tomdude22388, Mar 18, 2007.

  1. Tomdude22388

    Tomdude22388 Private E-2

    Hello. I am starting to learn C++. I am a new programmer and dont know much. Can any one explain to me in the simplest way what is Encapsulation, Inheritance and Polymorphism?
  2. ShockTroop

    ShockTroop Specialist

    Encapsulation is basically hiding code, mostly through the use of classes and private variables in object-oriented programming. This is so the outside can't directly access certain things.

    Inheritance is when one class is derived from another. If Class B inherits from Class A, Class B has everything in Class A plus anything else the programmer adds.

    Polymorphism is when one class inherits from another, but performs some methods differently. If Class B inherits from Class A, Class A might have a math() method that adds two numbers, while Class B might use the inherited math() method to multiply two numbers. They have the same name but do two different things. I think there's another aspect having to do with pointers to base classes, but I won't get into that.

    There are a couple pages on http://www.cplusplus.com that might explain these things better as well as give more examples.
  3. jarcher

    jarcher I can't handle a title

    I myself was reading about Encapsulation, Inheritance and Polymorphism today. .

    basicly hiding details of how a piece of software was written and only telling what is needed to understand the use of a class or oblect

    if you put your foot on the accelerator, the car goes.

    you dont need to know how it works( the cycle of air and gasoline, ignighting the mixture), thoes details aren't needed to drive a car.

    one methond name, used as an instruction, can cause differnt actions depending on what kind of object performs the action

    the best example I can come up with is:

    you can have the English instruction "go play your favorite video game".
    that could mean differant things to diffrant people

    there can be a method [output] that will output the data of an object. But what data and how much data it outputs depends on what kind of object carries out the action,

    is a way of organizing classes with properties in common that can be grouped together.

    like humans and apes are mammals. .but so are whales

    I hope that helps. .my spelling is awful I know. .but it is jus something that wea ll have to deal with. . . .rolleyes
  4. Tomdude22388

    Tomdude22388 Private E-2

    Thanks both of you. Everything is so clearer now. Thank you very much

Share This Page

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds