0

I have a .h file refer to a class file (.cpp), I am using CDT to modify code but i didn't find element node that refer to attribute of class for example :

#ifndef DEF_PERSONNAGE
#define DEF_PERSONNAGE

class simple 
{
    public:

    void recevoirDegats(int nbDegats);

    private:

    int m_vie;
};

#endif

I get the function declarator by testing if the node is instance of IASTFunctionDeclarator but to get the field int m_vie; i use what ?

wally
  • 10,717
  • 5
  • 39
  • 72
  • Possible duplicate of [How to access private data members outside the class without making "friend"s?](https://stackoverflow.com/questions/6717163/how-to-access-private-data-members-outside-the-class-without-making-friends) – wally Jan 30 '19 at 17:27
  • no i didn't find an answer there ! so it's not the same question. Me i focus on using CDT – Yassin Mohamadi Jan 30 '19 at 17:38

1 Answers1

0

we need to test that : the parent of this node is of type CPPASTDeclarator and the third parent is a class (mean of type ICPPASTCompositeTypeSpecifier) like that we ensure that this declaration is an attribute declaration for a class

for example name:IASTName

if ((name.getParent() instanceof CPPASTDeclarator) && (name.getParent().getParent().getParent() instanceof ICPPASTCompositeTypeSpecifier))