FY-1-d Best OOP program define function outside class

OOP program define function outside class

Write a program to demonstrate function definition outside class and accessing
class members in function definition.

Click here to get other OOP Practical

FYIT practical 1-c - Define function outside the class

#include<iostream>
using namespace std;

class Employee
{
char name[20];
char id[10];

public:
void getEmp();
void dispEmp();
};

void Employee::getEmp()
{
cout<<"Enter Employee Name : ";
cin>>name;
cout<<"Enter Employee ID : ";
cin>>id;
}

void Employee::dispEmp()
{
cout<<"Name : "<<name<<" & ID : "<<id;
}

int main()
{
Employee e = Employee();
e.getEmp();
e.dispEmp();
return 0;
}

Output

oop-program-define-function-outside-class​-itvoyagers

Check out more FYIT OOP Practical Program and other logic building programs in C++

We are aiming to explain all concepts of C++ and OOP in easiest terms as possible.
ITVoyagers-logo
ITVoyagers
Author

Leave a Comment