Computer Science Canada char |
Author: | aliveiswell [ Tue Dec 16, 2003 10:52 pm ] |
Post subject: | char |
I'm a little confused with this because in a tutorial I read it said that this variable will only hold 1 character. If this is true how do I make it hold more, or is there another variable I could use.thanks |
Author: | Tony [ Tue Dec 16, 2003 11:17 pm ] | ||||
Post subject: | |||||
you could ether use character arrays
or use string
|
Author: | wtd [ Mon Feb 09, 2004 11:22 am ] | ||||||
Post subject: | |||||||
tony wrote: you could ether use character arrays
or use string
Just one comment on this. The class name is "string". All lowercase. Second, it's in the std namespace, so unless you're "using namespace std;", you should fully qualify the name.
|
Author: | Andy [ Mon Feb 09, 2004 5:01 pm ] |
Post subject: | |
no... just have using namespace std; and just declare it by having string str; |
Author: | wtd [ Mon Feb 09, 2004 8:19 pm ] | ||||
Post subject: | |||||
dodge_tomahawk wrote: no... just have using namespace std;
and just declare it by having string str; Yeah, it's convenient, but it's best to use "using namespace" very selectively. Instead of:
Write something like:
That way it doesn't affect the entire program. After all, you might create another class named "string" elsewhere, and using the full name (std::string vs. util::string in a program I was writing today) will help avoid collisions. |
Author: | Andy [ Mon Feb 09, 2004 9:15 pm ] |
Post subject: | |
y would u create another string class??? |
Author: | Catalyst [ Mon Feb 09, 2004 9:36 pm ] | ||
Post subject: | |||
i like
then only the string name is taken not all the std ones |
Author: | wtd [ Mon Feb 09, 2004 10:09 pm ] |
Post subject: | |
dodge_tomahawk wrote: y would u create another string class???
I'm writing a virtual machine interpreter. The "string" type for the VM is the 32-bit location of the string in memory and its 32-bit length. |
Author: | rizzix [ Mon Feb 09, 2004 11:02 pm ] |
Post subject: | |
nice.. those are the things i like doing.. but.. i have no time heh for what language.. or have u designed ur own language as well ? i have designed the perfect language in mind.. after looking at Perl, java, c++, obj-c and python wow you can only imagine the language i have in mind.. (not necessarly bloated like c++ if that what ur thinking, it's more like perfect, well atleast to me) |
Author: | wtd [ Mon Feb 09, 2004 11:16 pm ] |
Post subject: | |
I'm writing it in C++. Templates and the STL really cut down the amount of work I have to do. I'd love to do it in Obj-C or Eiffel, but Eiffel doesn't have unsigned integer types, and Obj-C doesn't have templates. And clean C++ (without any C cruft) is actually really nice to develop in. |