Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Data Encapsulation

Data Encapsulation

Scheduled Pinned Locked Moved C / C++ / MFC
oopquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pix_programmer
    wrote on last edited by
    #1

    Hi! Can any one explain with reference the following code: (1)Where Data is encapsulated (At which line of code does the encapsulation)? (2) Where Data Abstraction is done(At which line of code does the abstraction)?

    #include "iostream"

    using namespace std;

    class Rectangle
    {
    private:
    float width,height,Area;
    public:
    Rectangle()
    {
    width = 35.0;
    height = 25.0;
    }

         Rectangle(float w, float h)
         {
            width = w;
            height =h;
         }
         void GetArea()
         {
          Area = width \* height;
          cout<<"Area of the rectangle is \\t"<
    
    L A 2 Replies Last reply
    0
    • P pix_programmer

      Hi! Can any one explain with reference the following code: (1)Where Data is encapsulated (At which line of code does the encapsulation)? (2) Where Data Abstraction is done(At which line of code does the abstraction)?

      #include "iostream"

      using namespace std;

      class Rectangle
      {
      private:
      float width,height,Area;
      public:
      Rectangle()
      {
      width = 35.0;
      height = 25.0;
      }

           Rectangle(float w, float h)
           {
              width = w;
              height =h;
           }
           void GetArea()
           {
            Area = width \* height;
            cout<<"Area of the rectangle is \\t"<
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Your <pre> tags have not been recognised: check your profile settings. For information on encapsulation and abstraction you should check some of these links[^].

      speaking as ...

      1 Reply Last reply
      0
      • P pix_programmer

        Hi! Can any one explain with reference the following code: (1)Where Data is encapsulated (At which line of code does the encapsulation)? (2) Where Data Abstraction is done(At which line of code does the abstraction)?

        #include "iostream"

        using namespace std;

        class Rectangle
        {
        private:
        float width,height,Area;
        public:
        Rectangle()
        {
        width = 35.0;
        height = 25.0;
        }

             Rectangle(float w, float h)
             {
                width = w;
                height =h;
             }
             void GetArea()
             {
              Area = width \* height;
              cout<<"Area of the rectangle is \\t"<
        
        A Offline
        A Offline
        Aescleal
        wrote on last edited by
        #3

        Encapsulation is bundling data together with the operations that operate on them. Abstraction is anything that makes you think at a higher level, i.e. less of the implementation of a lump of code and data is visible by inspection of it's interface. So maybe that'll give you an idea as to "which line" triggers those concepts. Oh, and I forgot to mention that the term "data encapsulation" is meaningless - encapulation refers to the bundling of operations and data together.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups