On Friday 28 March 2003 07:34 am, Derek Fountain wrote:
They seem extraordinarily incomplete.
That's often the nature of free software documentation, I'm afraid. :o( The SGI stuff is OK, though.
$ locate string.h | grep gcc
/opt/gcc-3.2/include/c++/3.2/bits/basic_string.h
$ less /opt/gcc-3.2/include/c++/3.2/bits/basic_string.h
// Components for manipulating sequences of characters -*- C++ -*-
...
// ISO C++ 14882: 21 Strings library
...
// Documentation? What's that?
// Nathan Myers
I'm trying to figure out things that should be simple, such as how to work with the string class.
Consider using a toolkit of some sort. The C++ standard library is horrible to work with and should be avoided where possible[*]. The best toolkit on the market at the moment is Qt[*], which isn't just a GUI toolkit, it gives data structures, strings, XML handling and all sorts of other stuff. Extremely well put together, excellent documentation and hundreds of examples. If you're doing GPL software, consider using Qt.
[* My opinion, others will differ.]
Oh, certainly. QT's fantastic, and wonderfully documented.
How do I create a string type variable within a class, and assign a value to it?
Does this help show the way?:
#include <string> #include <iostream>
int main( int argc, char *argv[] ) { std::string s;
s = "derek";
std::cout << s << "\n"; return 0; }
The following accomplishes the basic goal, but leaves several questions unanswered: #include <iostream> // cout, cin #include <string> using namespace std; // Thanks Tom Bradley. class HelloClass { public: void sayHello(); void setMessage(char * message="Hello C++ World"); private: string str; }; void HelloClass::setMessage(char * message){ str = message; } void HelloClass::sayHello() { cout << str << endl; } main() { HelloClass h; h.setMessage(); h.sayHello(); return 0; } How would I set HelloClass::str to something within the class definion, or constructor? IOW, how do I initialize member variables of user defined types to default values? STH