Data Encapsulation
-
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"<
-
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"<
Your <pre> tags have not been recognised: check your profile settings. For information on encapsulation and abstraction you should check some of these links[^].
-
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"<
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.