I think this is a reasonable question. There are several cases in C++ where order of text in the file does matter. This fortunately is not one of them - your two code samples are equivalent. As covered by Claudio, writing 'inline' in the source makes no difference either way.
Questions of the variety of "does this optimisation happen" are usually compiler dependent, so can best be answered by asking the compiler, for example:
# clang++ -c first.cpp -O3 -S -emit-llvm -o first.ll
; ModuleID = 'first.cpp'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%class.B = type { %class.A }
%class.A = type { i8 }
@str = private unnamed_addr constant [12 x i8] c"Func'ing A!\00"
; Function Attrs: nounwind uwtable
define void @_ZN1B1gEv(%class.B* nocapture readnone %this) #0 align 2 {
%puts.i = tail call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @str, i64 0, i64 0)) #1
ret void
}
; Function Attrs: nounwind
declare i32 @puts(i8* nocapture readonly) #1
attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind }
!llvm.ident = !{!0}
!0 = metadata !{metadata !"Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)"}
Or, if you prefer x86-64,
# clang++ -c first.cpp -O3 -S -o first.s
.text
.file "first.cpp"
.globl _ZN1B1gEv
.align 16, 0x90
.type _ZN1B1gEv,@function
_ZN1B1gEv: # @_ZN1B1gEv
.cfi_startproc
# BB#0:
movl $.Lstr, %edi
jmp puts # TAILCALL
.Ltmp0:
.size _ZN1B1gEv, .Ltmp0-_ZN1B1gEv
.cfi_endproc
.type .Lstr,@object # @str
.section .rodata.str1.1,"aMS",@progbits,1
.Lstr:
.asciz "Func'ing A!"
.size .Lstr, 12
.ident "Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)"
.section ".note.GNU-stack","",@progbits
Both snippets compile to exactly the same intermediate representation with clang 3.5 - most easily verified using a diff tool - so we can be confident that relative position in the source made no difference.
This is actually the case without optimisation as well (using -O0), at least for the compiler I'm using.