There are 2 ways to define a member function:
* Inside class definition. Note that all the member functions defined inside the class definition are by default inline, but you can also make any non-class function inline by using keyword inline with them.
* Outside class definition. To define a member function outside the class definition we have to use the scope resolution :: operator along with class name and function name.
```
#include <string>
#include <iostream>
using namespace std;
class Person
{
string name;
int id;
public:
Person(const string& name, int id):name(name), id(id) {}
void printName();
void printId() {
cout << "Id is: " << id << endl;
}
};
void Person::printName() {
cout << "Name is: " << name << endl;
}
int main() {
Person person{"bob", 1};
person.printName();
person.printId();
return 0;
}
```
C++11 introduced deleted and defaulted member functions.
A function in the form:
```
struct A{
A()=default; //C++11
virtual ~A()=default; //C++11
};
```
is called a defaulted function. The =default; part instructs the compiler to generate the default implementation for the function. Defaulted functions have two advantages: They are more efficient than manual implementations, and they rid the programmer from the chore of defining those functions manually.
The opposite of a defaulted function is a deleted function:
```
int func()=delete;
```
Deleted functions are useful for preventing object copying, among the rest. Recall that C++ automatically declares a copy constructor and an assignment operator for classes. To disable copying, declare these two special member functions =delete:
```
struct NoCopy{
NoCopy & operator =( const NoCopy & ) = delete;
NoCopy ( const NoCopy & ) = delete;
};
NoCopy a;
NoCopy b(a); //compilation error, copy ctor is deleted
```