Lost Temple

C++ provides 3 different access specifier keywords: public, private, and protected.

#include<iostream>

class Date
{
public:
    int m_nYear;
    int m_nDay;
    int m_n_month;

};

class Access
{
    int m_nA; //private by default
    int GetA(){return m_nA;}; //private by default

private:
    int m_nB; //private keyword to keep private
    int GetB(){return m_nB;}; //private keyword to keep private

protected:
    int m_nD; //protected keyword to keep protected
    int GetD(){return m_nD;};//protected keyword to keep protected

public:
    int m_nC; //public keyword to keep public
    int GetC(){return m_nC;}; //public keyword to keep public
};
int main()
{
    Date cDate;
    cDate.m_n_month= 06;
    cDate.m_nYear=2015;
    cDate.m_nDay=30;
    std::cout<< cDate.m_nYear<<"-"<<cDate.m_n_month<<"-"<<cDate.m_nDay<<std::endl;

    Access cAccess;
    cAccess.m_nC = 5;//ok because m_nC is public
    std::cout<<cAccess.GetC()<<std::endl; //ok becasue GetC() is public

    cAccess.m_nA = 2; // wrong because m_nA is private
    std::cout<< cAccess.GetA()<<std::endl; // wrong because GetA() is private

    return 0;
}