C function calls in C++ class namespace
c++, system-calls
Solution
Presumably you want to call `write(2)`, which is in the global namespace:
::write(filedes, str.c_str(), str.length());
(you might need to `#include <unistd.h>`).
Problem
I'm attempting to familiarize myself with C++ by way of a project, but I have hit an error that I am not quite sure how to deal with. I have the following code: ``` void myclass::write(std::string str) { write(filedes, (void *)str.c_str(), str.length()); } ``` Where filedes is an instance variable of myclass. Attempting to compile this yields the error: ``` myclass.cpp: In member function ‘void myclass::write(std::string)’: myclass.cpp:38: error: no matching function for call to ‘myclass::write(int&, void*, size_t)’ myclass.cpp:37: note: candidates are: void myclass::write(std::string) myclass.hpp:15: note: void myclass::write(std::string, int) ``` So what am I doing wrong? Can I not legally make this function call from the method?