Defining Methods outside the Class definition in c++
This video tutorial explains how to define methods outside the class definition in c++.
You will learn how to use scope resolution operator to define methods of a class, how to access the properties using scope resolution operator in detail with example.
source code for this tutorial
#include <iostream>
#include <string>
using namespace std;
class Human{
public:
string name = "noname" ;
void introduce();
};
void Human :: introduce(){
cout << Human ::name <<endl;
}
int main()
{
Human anil;
anil.introduce();
return 0;
}