How do I...
-
Can you tell me please how to pass strings as parameters of a function so we can use them for different purposes?Please help me !!!!
void foo1( LPCTSTR lpszName )
{
// do something with lpszName
}or
void foo2( CString &strName )
{
// do something with strName
}
...
foo1("My name is...");
CString str("Bob");
foo2(str);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
void foo1( LPCTSTR lpszName )
{
// do something with lpszName
}or
void foo2( CString &strName )
{
// do something with strName
}
...
foo1("My name is...");
CString str("Bob");
foo2(str);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
you forgot:
include using std::string void foo3( string s) { }
not to mention char *. Is LPCTSTR a macro that converts to narrow and wide strings ? Then there's BSTR and bstr_t...... Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer -
you forgot:
include using std::string void foo3( string s) { }
not to mention char *. Is LPCTSTR a macro that converts to narrow and wide strings ? Then there's BSTR and bstr_t...... Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard StringerI guess it's better to replace
using std::string;
byusing namespace std;
or else the class 'string' will not be available (it's 'std::string', not 'std::string::string'). LPCTSTR is not really a macro:#define LPCTSTR const char*
(or something like that, I probably forgot the As and Ws for ANSI and Unicode) -
I guess it's better to replace
using std::string;
byusing namespace std;
or else the class 'string' will not be available (it's 'std::string', not 'std::string::string'). LPCTSTR is not really a macro:#define LPCTSTR const char*
(or something like that, I probably forgot the As and Ws for ANSI and Unicode)DaFrawg wrote: I guess it's better to replace using std::string; by using namespace std; Nope, that's rubbish. That scopes all of namespace std unnecessarily, if std::string is all that is wanted. DaFrawg wrote: or else the class 'string' will not be available (it's 'std::string', not 'std::string::string'). You're completely wrong here. I don't even know how you ended up with this theory. DaFrawg wrote: LPCTSTR is not really a macro: #define LPCTSTR const char* (or something like that, I probably forgot the As and Ws for ANSI and Unicode) That is, by definition, a macro, just a parameterless one. Thanks for playing tho. :-) Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
-
you forgot:
include using std::string void foo3( string s) { }
not to mention char *. Is LPCTSTR a macro that converts to narrow and wide strings ? Then there's BSTR and bstr_t...... Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard StringerChristian Graus wrote: you forgot: Technically speaking, yes. Since STL and Unicode are not part of my normal development paradigm, I don't often think of them.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
Christian Graus wrote: you forgot: Technically speaking, yes. Since STL and Unicode are not part of my normal development paradigm, I don't often think of them.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
*grin* To be honest, Unicode has never figured highly in my thoughts either. But I was always an STL junkie :-) Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
-
DaFrawg wrote: I guess it's better to replace using std::string; by using namespace std; Nope, that's rubbish. That scopes all of namespace std unnecessarily, if std::string is all that is wanted. DaFrawg wrote: or else the class 'string' will not be available (it's 'std::string', not 'std::string::string'). You're completely wrong here. I don't even know how you ended up with this theory. DaFrawg wrote: LPCTSTR is not really a macro: #define LPCTSTR const char* (or something like that, I probably forgot the As and Ws for ANSI and Unicode) That is, by definition, a macro, just a parameterless one. Thanks for playing tho. :-) Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
Christian Graus wrote: Nope, that's rubbish. That scopes all of namespace std unnecessarily, if std::string is all that is wanted. Sorry, I didn't know that there was something like "using Declaration". MSDN: "The using declaration introduces a name into the declarative region in which the using declaration appears." :-O Christian Graus wrote: That is, by definition, a macro, just a parameterless one. Tell that the people who claim they are called "symbolic identifiers". :rolleyes:
-
Christian Graus wrote: Nope, that's rubbish. That scopes all of namespace std unnecessarily, if std::string is all that is wanted. Sorry, I didn't know that there was something like "using Declaration". MSDN: "The using declaration introduces a name into the declarative region in which the using declaration appears." :-O Christian Graus wrote: That is, by definition, a macro, just a parameterless one. Tell that the people who claim they are called "symbolic identifiers". :rolleyes:
DaFrawg wrote: Sorry, I didn't know that there was something like "using Declaration". NP. Glad to help you learn somethng new. The using declaration is better because you control what gets pulled into global scope. Otherwise, you have no real idea. DaFrawg wrote: Tell that the people who claim they are called "symbolic identifiers". They just say that because macros are evil, but a rose by any other name.... Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer