problem when creating a class called link and using string

When compiling the following code, my actual link class is more complex, i got the error message:
link.cpp: In function ‘int main()’:
link.cpp:19: error: expected ‘;’ before ‘lA’

if i don't use string it works. Someone knows about this problem.

CODE:
#include <string>
class link{
public:
link();
~link();
};

link::link() {
}

link::~link() {
}

int main()
{
link lA;
return 0;
}
Apparently <string> on your platform declares C++ versions of system functions such as link()[1] and linkat()[2]. If you use the -E switch, it will output preprocessed source. Doing that for <string> reveals the following on my PC:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
extern int ttyslot (void) throw ();




extern int link (__const char *__from, __const char *__to)
     throw () __attribute__ ((__nonnull__ (1, 2))) ;




extern int linkat (int __fromfd, __const char *__from, int __tofd,
     __const char *__to, int __flags)
     throw () __attribute__ ((__nonnull__ (2, 4))) ;


[1] - http://www.kernel.org/doc/man-pages/online/pages/man2/link.2.html
[2] - http://www.kernel.org/doc/man-pages/online/pages/man2/linkat.2.html
Topic archived. No new replies allowed.