Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Compiler error in calling friend function!!??



  • i declared a friend function in one class...as shown below...

    classa.h

    @ class A
    {
    public:
    friend void friendFunction(void);
    void somefunction(void);
    .................
    }@

    classa.cpp

    @
    void class A::somefunction()
    {
    ......
    friendFunction();
    }
    @

    main.cpp
    @
    ..........
    .............
    void frienFunction(void)
    {
    /* function implementation...*/
    }

    @

    but i'm getting compiler error saying that "friendFunction not declared in this class"
    please help me whats the wrong here!??



  • It's not relevant to Qt but you should add another declaration of friendFunction() before definition of class A.


Log in to reply