Why does compiler fail to see functions declared with the friend specifier when compiling with mingw? Error: such a function was not declared in this scope. Maybe what flags are needed?

  • I would like to see how you declare it. - BuilderC 1:56 pm
  • Text to the studio - skegg

1 answer 1

Understood. Here is an example:

#include <iostream> using namespace std; struct A { public: friend A function(); void rotate(char g); }; A function() { cout << " text" << endl; } void A::rotate(char g) { cout << g; function(); } int main(int argc, char* argv[]) { A s; s.rotate('A'); return 0; } 

The error fell out when A function () {cout << "text" << endl; } comes after void A :: rotate (char g) ... now everything is compiled