'VS reporting error with every variable of a class

I have realized a typical class called "FCB", and VS didn't report any problem while I was coding, and can recognize its members when referred to. Yet as I try to compile it, it shows that every variable whose type is FCB or FCB* appear to be unrecognizable. Here is my class.

FileControlBlock.h

#pragma once

#include <string>
#include <vector>
#include <iostream>
#include <unordered_map>
using namespace std;

#include "hash.h" //a custom head file that I use to use string as hash index

//file authority
#define AUTH_ALL 0
#define AUTH_NO_DEL 1
#define AUTH_READ_ONLY 2
#define THIS_DIR 0
#define CHIL_DIR 1
#define SUC 0
#define ERR -1
#define C_ERR_DUP_NAME -1
#define C_ERR_ILL_NAME -2
#define D_ERR_LACK_AUTH -1
#define D_ERR_IS_OCCUPY -2
#define R_ERR_IS_WRITE -1
#define W_ERR_IS_OCCUPY -1

extern FCB* POS_POINTER;

class FCB
{
public:
    string name;        //file name
    char type;          //directory(.f), .exe(.e), .txt(.t)
    FCB* parent;
    int size;
    int auth;
    //only for directories
    unordered_map<unsigned int, FCB> directoryTree;

    string printRoute();            //print the route
    vector<FCB> saveDirectory();
    FCB* findFile(string fileName); 
    vector<string> printFile(char fileType);//find a certain kind of file
    FCB(string fileName = "~", int fileSize = 0);
    string printDirectory(string dirRoute = ".", int mode = THIS_DIR);
};

FCB::FCB(string fileName, int fileSize)
{
    this->name = fileName;
    int nameLen = fileName.size();
    this->type = fileName[nameLen - 1];
    this->parent = POS_POINTER;
    this->size = fileSize;
    this->auth = POS_POINTER->auth;
}

string FCB::printRoute()
{
    string route = this->name;
    return route;
}

string FCB::printDirectory(string dirRoute, int mode)
{
    string result = "";
    return result;
}

vector<string> FCB::printFile(char fileType)
{
    vector<string> result;
    return result;
}

vector<FCB> FCB::saveDirectory()
{
    vector<FCB> result;
    return result;
}

FCB* FCB::findFile(string fileName)
{
    FCB* result = NULL;
    return result;
}

FileSystem.h(it is not completed yet)

#pragma once
#include <fstream>
#include "FileControlBlock.h"

#define WRITE_HEAD 0
#define WRITE_TAIL 1
#define MAX_NAME_LEN 16

//save on the computer
const string dirLoc = "PD_OS_FS\\directory.txt";

class FileSystem
{
public:
    FCB myDir;
    FileSystem();
    ~FileSystem();
    int changeRoute(string route);  
    int creatFile(string fileName);
    int deleteFile(string fileName);
    int readFile(string fileName, int pid);
    int writeFile(string fileName, string writeObj, int mode, int pid);
};

main.cpp

#include "FileSystem.h"

FCB* POS_POINTER = NULL; //位置指针

int main()
{
    return 0;
}

There is nothing special with my main(), and the error info is as follow: enter image description here Sorry that I can't translate it into English. Basically, myDir is a member of another class "FileSystem" whose type is FCB, but VS reports that myDir does not belong to FileSystem. Most of the errors are like that, related with class FCB, as if there is no such class.



Solution 1:[1]

Like @RichardCritten ’s comment, I wrongly declared POS_POINTER before FCB. Just move it after the class and before the member functions will fix most of the porbl

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lydia