lundi 1 mars 2021

Cannot access a private struct in cpp file that is declared in a header file

Header.h

Class A{

private:
struct Student
    {
        std::string name;
        uint32_t rollno;
    };

}

Codefile.cpp

#include "Header.h"
namespace
{
     const A::Student students[] = {
     {"Luffy", 1},
     {"Zoro", 2}, 
     };
}

const A::Student throws an error saying that Student is inaccessible in codefile.cpp. How do I make a struct Student variable declared as a private variable in header file accessible in an unnamed namespace in a cpp file?

Aucun commentaire:

Enregistrer un commentaire