Example & Tutorial understanding programming in easy ways.

How make function in classes in C++ ?

What is Data Method?
In C language we have a function, so data method are nothing new they are also function but in many programming language like C++, java etc function are called as data method.
-function inside class called as data method

How make function or data method inside class?

program:

#include< iostream>
using namespace std;
//Create class
class myclass
{
public:
//Create data method
int func()
{
cout<<"This is my function";
}
};
int main()
{
//create object
myclass obj;
//call data method
obj.func();
return 0;
}


output-

This is my function

-In this program, we create a class and then create a simple function named as 'func()' which print one statement.




Read More →