Class Access Modifiers
Class Access Modifiers
#include <iostream>
using namespace std;
class Line
{
public:
double length;
void setLength(double len);
double getLength();
};
double Line::getLength(void)
{
return length;
}
void Line::setLength(double len)
{
length = len;
}
int main()
{
Line obj;
obj.setLength(100);
cout << "\n Length of line : " << obj.getLength() << endl;
obj.length = 10;
cout << "\n Length of line : " << obj.length << endl;
return 0;
}
};
private:
double width;
return 0;
return 0;