I have two classes, one called Grocery and the other one called Strings
In the Grocery.cpp I’m trying to use a function from the “Strings” class called : “copyString” and I get the following error:
identifier “copyString” is undefined
The “Strings” class is just a generic Class for the base string function such as : strcmp, strcpy and so on….
In the “Grocery” class I don’t want to create a “Strings” object but using It like a the “Math” class is being used in C#. Just indicating the class name and using a dot to call a function of the Class.
How can I create a class “Strings” with the same functionality as the “Math” class in C# I described above?
Thanks a lot!
Guy
Either you have a class
Strings, with a methodgetStringLength(), in which case you need to callgetStringLength()on aStringsinstance:or you have a namespace
Stringswith the method, in which case you need to call it like this:If the function is not related to the
Stringsclass, consider making it a non-member function, in a suitable namespace:Strings.h:
Strings.cpp: