Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Compiler error in calling friend function!!??

    C++ Gurus
    2
    2
    1384
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      aurora last edited by

      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!??

      1 Reply Last reply Reply Quote 0
      • P
        p-himik last edited by

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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post