Re: newbie String question
Why are you returning a "string" object when your function return type is "int"?
Your function prototype should be.
string Process::GetBuno(const string& buno);
Re: newbie String question
Sorry... Meant to have say this..
int Process::GetBuno(const string& buno)
{
int number;
// some code
return number;
}
Re: newbie String question
You also need to observe the fact that string is declared in the std namespace. Add the following to your .h and .cpp files:
Re: newbie String question
In your class header get rid of
Process::
it should just be
int GetBuno(const string& buno);
Re: newbie String question
Ok...that helped some... still getting the same errors...and
error C2061: syntax error : identifier 'string'
Re: newbie String question
Thanks Bob and Engineer..that got it!
Re: newbie String question
Quote:
Originally Posted by Bob Davis
You also need to observe the fact that string is declared in the std namespace. Add the following to your .h and .cpp files:
Preferable not to do that in header files, but you might do it in .cpp files.
Re: newbie String question
All the classes of the STL are residing in their own namespace which is 'std'.
The following shows you the four different methods to map a namespace...
Code:
// Using the full member name, including the namespace it belongs to:
std::cout << "Hello World";
// By taking advantage of Using-Declarations:
using std::cout; // This declares cout in the current
// scope as synonym for std::cout
cout << "Hello World";
// By taking advantage of Using-Directives:
using namespace std; // Which specifies that the current
// scope can refer to names in the
// 'std' namespace without using
// full qualifiers. This is mostly
// used when porting legacy code.
cout << "Hello World";
// Using aliases:
namespace X
{
namespace Y
{
class Z { ... };
}
}
X::Y::Z // The full qualifier for 'Z' is
// 'X::Y::Z'
namespace w = X::Y; // This declares 'w' as an alias for
// namespace 'X::Y'
w::Z // Access 'Z' using 'w::Z'
Re: newbie String question
Quote:
Originally Posted by NMTop40
Preferable not to do that in header files, but you might do it in .cpp files.
Good point. Inside the header file, it would be advisable to use the fully-qualified name for the class; i.e. std::string. Putting "using" declarations in header files might inadvertently bring classes into the global namespace when you include those headers in other source files.