tags:

views:

52

answers:

2

Hi All, I am new to cpp, I have a small problem, I have a cpp file and it contains open(), read() & close() & some other methods as public members. Now I wanted to use the 'read' unix system call in one of the methods But if I do so (in some method) its pointing to class member variable 'read()' and gives compilation error. So, how to use the unix system calls such as 'open, read, close' in the cpp? if not so any other alternative to use?

Thanks-opensid

+6  A: 

If you are in a class that has a method read(), and you want to access a function read() in the global namespace, use ::read().

Jeff Dege
it worked... Thanks alot
sid
"it worked... Thanks alot" is usually expressed on StackOverflow as a green tick next to the answer ;-)
Johnsyweb
...and be thankful that `read` isn't a `#define`'d constant that evaluates to either `readA` or `readW` based on another preprocessor constant.
bk1e
+1  A: 

Try ::read(). The double colons take you to the top empty namespace.

mirzapirza
Err.. it wouldn't be much use if it was empty. :/
Billy ONeal
it worked... Thanks alot
sid
@Billy: Close your eyes and take yourself to the empty global namespace… isn't that nice?
Potatoswatter
Empty global namespace is the natural habitat of the unicor ;) And the former is as abound as the latter.
Dummy00001