Class Member Functions in C++

#include <iostream>
using namespace std;

class MyClass
{
public:
    int i;
    void myfunc();
    void myfunc2()
    {
        cout << " Print some message" << endl;
    }
};

void MyClass::myfunc()
{
    cout << "Hello World!" << endl;
}
int main()
{
    MyClass m;
    m.i = 50;
    cout << "Value is :" << m.i << endl;
    m.myfunc();
    m.myfunc2();

    return 0;
}

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *