C++ Class static function

Description

C++ Class static function

#include <iostream>
#include <string>

using namespace std;

class Util//  www  . j  av  a  2s.  co m
{
public:
    static string MyClassName() {
        return "Util!";
    }
    int myInt;
    int Chew(string name) {
        cout << myInt << endl;
        cout << name << endl;
        return myInt;
    }
};

int main()
{
    typedef string (*StaticMember)();
    StaticMember staticfunc = &Util::MyClassName;
    cout << staticfunc() << endl;
}



PreviousNext

Related