Defining a Class with a Member Function - C++ Class

C++ examples for Class:Class Creation

Description

Defining a Class with a Member Function

Demo Code

#include <iostream>

class MyClass {/*from   w w  w  .ja v  a  2s  .c o m*/
 public:
    void displayMessage() {
        std::cout << "Welcome to the Grade Book!" << std::endl;
    }
};

int main(int argc, const char *argv[]) {
    MyClass myMyClass;  // create a MyClass object named myMyClass

    myMyClass.displayMessage();

    return 0;
}

Result


Related Tutorials