Thursday, August 3, 2017

Class Age in C++

A very simple program that I wrote using classes and object oriented programming in C++ a long time ago that I would like to share to my fellow programmers around the world who visited my website. I hope you will learn from this simple program. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.



Program Listing


#include <iostream>

using namespace std;

class age {
    int ages;
    public:
     int getdata();
     void display(void);
};


int age:: getdata()
{
    cout << "Enter the age of the person : ";
    cin >> ages;
    if (ages >= 18) {
        cout <<"\n The person is Already an Adult.";
    }
    else
     {
        cout <<"\n The person is Still a Minor.";
    }

}

void age:: display(void)
{
    int value;
    value = getdata();
}


main()
{
    age start;
    start.display();
}



No comments:

Post a Comment