class
myClass;class
otherClass {public
:otherClass(int x): valor(x) {}
inline int sum(myClass &obj);
private
:int valor;
};
class
myClass {public
:myClass(int x): val(x) {}
friend otherClass::sum(myClass&);
private
:int val;
};
inline
int otherClass::sum(myClass &obj) {return obj.val + valor;
}
The above is a minimalist example to illustrate the problem at hand.
Note how the friend declaration is not defining the return type of otherClass::sum() and yet Warning C4430 is not being thrown.
Is this a bug Or is there some compiler option I'm setting that precludes the warning
This is my compiler's command line:
/Od /D "_WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FD /EHsc /MDd /Gy /Za /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W4 /nologo /c /Zi /TP /errorReport:prompt

Warning C4430 not being thrown in friend declaration
edburdo
Curious, because this piece of code, generates C4430:
class foo
{
friend operator==(const foo& f1, const foo& f2);
};
eza
John Black
dan kisting
Wouldn't that be the same as state that any function declaration does not require a return type We know that is not true. Previous compilers assumed int. That is no longer the case.
When I include the return type, no warning is generated. Which is as expected, since when I include the return type I'm following ISO (read 7.1 and 11.4).
Adrian_Peirson