-1

When I am checking declarations from string.h file, I saw these things:

friend inline void     cat(const String&,const SubString&,const String&,String&);
inline friend void     cat(const String&,const SubString&,const String&,String&);

What is the difference between them?

Mureinik
  • 297,002
  • 52
  • 306
  • 350
Madhu Kumar Dadi
  • 695
  • 8
  • 25

2 Answers2

6

There's no difference. Both friend and inline are independent declaration specifiers, which can be specified in any order.

There's not much point in declaring the function inline in a friend declaration though. More generally, there's no point in specifying inline in any non-defining function declaration. inline makes more sense when applied to a function definition.

AnT stands with Russia
  • 312,472
  • 42
  • 525
  • 765
0

The friend and inline modifiers can be used independently, and their order has no impact. E.g., inline friend foo() is the same as friend inline foo().

Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • and inline function means function can be used in the functions defined in same file. Right? – Madhu Kumar Dadi Jul 02 '15 at 16:49
  • 1
    @MadhuKumar no. `inline` is a hint to the compiler to replace the function call with its implementation (i..e, to *inline* it). Theoretically, this should provide some performance benefit, especially if the function is short, so the code doesn't get bloated (see also http://en.cppreference.com/w/cpp/language/inline) – Mureinik Jul 02 '15 at 16:52
  • The original post was edited; now the parameters are the same. – Dan Korn Jul 02 '15 at 16:55
  • @DanKorn edited away the piece about overloading, which, as you noted, no longer relates to the question. – Mureinik Jul 04 '15 at 08:16