Basic C++ class and object program









 

This is a basic program of class and object C++ :

program :
#include <iostream>
using namespace std;
class age
{
    int age;
    char name[2];
public:
    void get()
    {
        cout<<"enter your age and name: ";
        cin>>age>>name;
    }
    void dis()
    {
        cout<<"name is "<<name<<",age is "<<age;
    }
};
int main()
{
    age a1;
    a1.get();
    a1.dis();
    return 0;
}

output :



Comments

Popular posts from this blog

swapping first and last digits of a number :Python Program

infix to postfix expression converter in "C" language

Implementation of Stack with Singly Linked List : C Program