Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Compiler error in calling friend function!!??
QtWS25 Last Chance

Compiler error in calling friend function!!??

Scheduled Pinned Locked Moved C++ Gurus
2 Posts 2 Posters 1.5k Views
  • 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 Offline
    A Offline
    aurora
    wrote on last edited by
    #1

    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
    0
    • P Offline
      P Offline
      p-himik
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved