"oop encapsulation example" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "oop encapsulation example" answered properly. Developers are finding an appropriate answer about oop encapsulation example related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like oop encapsulation example. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on oop encapsulation example.
oop encapsulation example
#include<iostream>
using namespace std;
class ExampleEncap{
private:
/* Since we have marked these data members private,
* any entity outside this class cannot access these
* data members directly, they have to use getter and
* setter functions.
*/
int num;
char ch;
public:
/* Getter functions to get the value of data members.
* Since these functions are public, they can be accessed
* outside the class, thus provide the access to data members
* through them
*/
int getNum() const {
return num;
}
char getCh() const {
return ch;
}
/* Setter functions, they are called for assigning the values
* to the private data members.
*/
void setNum(int num) {
this->num = num;
}
void setCh(char ch) {
this->ch = ch;
}
};
int main(){
ExampleEncap obj;
obj.setNum(100);
obj.setCh('A');
cout<<obj.getNum()<<endl;
cout<<obj.getCh()<<endl;
return 0;
}
Source: beginnersbook.com
All those coders who are working on the Whatever based application and are stuck on oop encapsulation example can get a collection of related answers to their query. Programmers need to enter their query on oop encapsulation example related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about oop encapsulation example for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of oop encapsulation example while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "oop encapsulation example". Visit this developer's friendly online web community, CodeProZone, and get your queries like oop encapsulation example resolved professionally and stay updated to the latest Whatever updates.