I have
// file BoardInitializer.h
#include <stdio.h>
#include <tchar.h>
#include <string>
#include <iostream>
using namespace std;
class BoardInitializer
{
static int *beginBoard;
static int *testBoard;
static void testBoardInitialize();
}
// file mh.cpp
#include "BoardInitializer.h"
int main(int argc, char* argv[])
{
BoardInitializer.testBoardInitialize();
return 0;
}
and I implemented BoardInitializer::testBoardInitialize in mh.cpp.
But I get the error “Function is inaccessible”. What’s wrong?
The default protection level for a
classin C++ isprivate(withthe others being
publicandprotected). That means all yourmembers and your member function are private and only accessible by
other member functions of that class or friends (functions or classes)
of that class.
The function main is neither and you end up with the error.
C++ provides a handy shortcut (or C legacy cruft, depending on your
worldview) called
struct, where the default protection level ispublic.or
should show the difference.