If I had:
How could i use the strlen() defined in string.h ?Code:#include <string.h> class someClass { public: someClass(); private: void strlen(); }; void someClass::strlen() { // do something like exit(0); }
If I had:
How could i use the strlen() defined in string.h ?Code:#include <string.h> class someClass { public: someClass(); private: void strlen(); }; void someClass::strlen() { // do something like exit(0); }
If you want to use the strlen function directly with your class, that is so it could access private data of you class make it a friend by using the friend token. However the strlen() function is already defined so I'm not exactly sure what your asking.
What is the purpose ofvoid strlen();
Well that was an example. I want to know how i can use native functions from a class with a member with the same name.
In c++ you may have many functions that have the same name as long as their signatures are different, that is their argument list. Therefore you could use a function called strlen() as long as it had a different argument list from the one defined in the String header file. For example:
These functions all have different signatures and are therefore allowed to have the same name. I hope this helps.Code:int DoThis(void); int DoThis(int, double); int DoThis(char *);
std::strlen(/*whatever*/); or ::strlen(/*whatever*/); depending on how compliant your compiler is. Since you're including <string.h> it will probably be the latter. Try to make a habit out of using the new headers <cxxx> (so <string.h> becomes <cstring>).How could i use the strlen() defined in string.h ?
- lmov