Define function outside the class in C++ by R4R Team

How define function outside class in C++:
-We define a function outside the class using scope resolution operator(::)

program:

#include < iostream>

using namespace std;
class Myclass
{
public:
void function();
};
void Myclass::function()
{
cout<<"This is my function outside class";
}
int main()
{
Myclass obj;
obj.function();
return 0;
}


output-

This is my function outside class




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!