difference between function and method
#inclue<iostream>
using namespace std; // Bad Practice!!!
/*
*******IF YOU DONT KNOW OOP(OBJECT ORIENTED PROGRAMMING) FIRST LEARN IT THEN COME HERE
AGAIN*******
Simply, Method = Function.
But Difference is that
We call a Function A 'Method' When That Function Is Written Inside a Class(a blueprint)
But if that Function is not Declared inside a class body then we call it 'Function'
*/
//Example:
class Employee
{
public:
void getData(void); // This Is A 'METHOD'
}
void Employee :: getData(void) // This is Also A Method Because It Is Pointing Towards The GetData Function In Employee Class.
{
cout<<"GET DATA!!!!!!"<<std::endl; // Good Practice (std::endl) use "std::"
}
int main() // This Is A Function, Cause It's Not Pointing Towards The Class As Well As Not Initialized Inside The Class Body
{
cout<<"Hello"<<endl;
return 0;
}
void DoSomethingGood(void) // This Is A Function As Well.
{
if (2+2==5)
return;
}