error: function declared as inline variable HELP!

I am following a book on c++ and I have got stuck with this. There is a separate .h file with the add function in it and a .cpp file with a main function in it.
My code is identical to whats in the book but I get this error:

In file included from guard.cpp:2:0:
triple.h:3:21: error: 'triple' declared as an 'inline' variable
inline int triple (x) {return add(x, add(x, x));}

And then lots of other errors similar to it.

Below is the code in the triple.h header file. Please help!

1
2
3
  #include "add.h"

  inline int triple (x) {return add(x, add(x, x));}
inline int triple (x) {return add(x, add(x, x));}
This looks like some kind of messed up preprocessor macro masquerading as a function, and I'm not surprised it doesn't compile.

If it was a function, it would have the type of that input parameter in there:
inline int triple (int x) {return add(x, add(x, x));}

What's in the header file? What book?
1
2
3
  #include "add.h"

  inline int triple (int x) {return add(x, add(x, x));}


I found the problem. I should have put "int" before the x

But in the book it just has an x. Weird...
Topic archived. No new replies allowed.