The polymorphism section of the C++ tutorial starts out saying that if
you should go back and reread the Classes section (it doesn't say Classes I or Classes II, so I reread both).
As far as I can tell, this snippet assumes that you have some typedef for
c, and that
b is a function member of class
a that takes a
c and returns an
int, although in this case control reaches the end of
b without returning a value explicitly, so the value that will actually be returned is effectively random (i.e., undefined).
The following code:
#include <iostream>
using namespace std;
typedef int c;
class a
{
public:
int b( c );
} ;
int a::b(c) {};
int main()
{
a foo;
a a;
cout << foo.b( 10 ) << endl << a.b(8);
return 0;
} |
compiles, with the expected warning about control reaching the end of a non-void function.
Is this the intended (only) interpretation of the snippet from the tutorial, or am I missing something?