mardi 11 août 2020

Compiling error for a class with static members in C++

I created a class with static members but I faced a compiling error which is "a storage class can only be specified for objects and functions.".

What's the solution?

#include<iostream>
using namespace std;

static class Hi {

    public: static string ShowMessage(string Message)
    {
        return Message;
    }
};

int main()
{
    cout << Hi::ShowMessage("Hello");
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire