inline function question

H

hpy_awad

I was writing an example from a book of Borland C++. At is wrote as it
is. I found those errors :
Can't have a non-inline function in a local class
Identifier GetX can't have a type qualifier.
Here is the code :
*-----------------

#include <stdio.h>
main (void)
{
enum boolean { false , true };

// This the second method of declaration
struct point
{
int X,Y;
boolean visible;
int GetX2();
};

int point::GetX()
{
int n=9;
return n;
};

return 0;
}
 
J

Joona I Palaste

(e-mail address removed) <[email protected]> scribbled the following
I was writing an example from a book of Borland C++. At is wrote as it
is. I found those errors :
Can't have a non-inline function in a local class
Identifier GetX can't have a type qualifier.
Here is the code :

Why are you posting C++ code to comp.lang.c? Why not try
comp.lang.fortran while you're at it?

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"You have moved your mouse, for these changes to take effect you must shut down
and restart your computer. Do you want to restart your computer now?"
- Karri Kalpio
 
V

Victor Bazarov

I was writing an example from a book of Borland C++. At is wrote as it
is.

How old is the book?
I found those errors :
Can't have a non-inline function in a local class
Identifier GetX can't have a type qualifier.

Yes. What's your question? What to do? Put the body of the
offending function inside the class definition.
Here is the code :
*-----------------

#include <stdio.h>
main (void)

int main()
{
enum boolean { false , true };

'bool' is now a built-in type. You don't need your 'boolean' any
longer.
// This the second method of declaration
struct point
{
int X,Y;
boolean visible;
int GetX2();
};

int point::GetX()

'point' does NOT have 'GetX' member. You need to have your names
straight. It's either 'GetX2' (as in the class definition) or 'GetX',
then you need to fix the class definition.
{
int n=9;
return n;
};

return 0;
}

Besides, you never use your 'struct point'. So, what's the point
(the pun's intended)?

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,142
Messages
2,570,818
Members
47,362
Latest member
eitamoro

Latest Threads

Top