You can't do that -- the dot simply isn't allowed in a C or C++ function name:
Ie for
#include <stdlib.h>
int foo.bar(int x) {
return(2*x);
}
int main(void) {
foo.bar(21);
exit(0);
}
we get
edd@max:/tmp$ gcc -c foo.c
foo.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
foo.c: In function ‘main’:
foo.c:9: error: ‘foo’ undeclared (first use in this function)
foo.c:9: error: (Each undeclared identifier is reported only once
foo.c:9: error: for each function it appears in.)
edd@max:/tmp$
and
edd@max:/tmp$ g++ -c foo.c
foo.c:4: error: expected initializer before ‘.’ token
foo.c: In function ‘int main()’:
foo.c:9: error: ‘foo’ was not declared in this scope
edd@max:/tmp$
In C++, foo.bar()
is calling the member function bar()
of object foo
.