Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - RetroX

541
Announcements / Re: Another choice.
« on: March 16, 2010, 06:51:20 PM »
Also, I'd really like to see an English->French translator hard coded over the two languages' twelve similarities.
You mean not like Google translator!?!?

Where one person can suggest a translation and it becomes completely inaccurate!?

542
Announcements / Re: Another choice.
« on: March 15, 2010, 08:48:42 PM »
Why not use ++ and -- instead of +=1 and -=1?

543
Announcements / Re: Quick Poll
« on: March 14, 2010, 04:44:34 PM »
I never make semicolon mistakes on anything but struct or class.  :/

The GCC gives good enough syntax error reporting to not have to worry about it.

544
Announcements / Re: Quick Poll
« on: March 14, 2010, 02:42:10 PM »
GM treats var x,y as bad syntax without a semicolon; the same should apply to struct and class.

545
Tips, Tutorials, Examples / Re: lol streams
« on: March 06, 2010, 03:25:17 PM »
That's const char*

char* would mean something like this:
Code: [Select]
char x[]={'h','e','l','l','o',',',' ','\0'};
char y[]={'d','a','m','n','i','t','\0'};
char *z=x+y;
or
Code: [Select]
char *z=const_cast<char*>("hello, ")+const_cast<char*>("damnit");
Wait, what?
Exactly.  It's pointless.

546
Tips, Tutorials, Examples / Re: lol streams
« on: March 05, 2010, 10:04:53 PM »
The only difference between const char* and char* is that const char* points to read-only memory. And even that's only on systems that support such (ie, not Windows). '\0' == 0, and I'd be willing to bet that if you were to compare {'n','o',0} and "no" you'd get that they were equivalent. And I do mean as-is.

"Test" == "test" compares correctly for string literals. "Test" == "test" will return false, "test" == "test" will return true. This is because they point to the same location in memory when GCC is done with them.

Also, you don't need to use const_cast to get it represented as a const char. :P
Const char* can be set to a char* without cast. Vice-versa requires cast, but is dangerous on Linux and the like.
Whenever I have tried to do it without const_cast, G++ bugs me about a depreciated conversion (that works).  I always use -Wall and purge all warnings and errors, and that is one that I happen to get into the habit of doing.

547
Tips, Tutorials, Examples / Re: lol streams
« on: March 05, 2010, 09:37:59 PM »
That's const char*

char* would mean something like this:
Code: [Select]
char x[]={'h','e','l','l','o',',',' ','\0'};
char y[]={'d','a','m','n','i','t','\0'};
char *z=x+y;
or
Code: [Select]
char *z=const_cast<char*>("hello, ")+const_cast<char*>("damnit");

548
Tips, Tutorials, Examples / Re: lol streams
« on: March 05, 2010, 09:30:16 PM »
Erm, why would you want to do that?  That's kind of the point of string - to add things like that.

549
Tips, Tutorials, Examples / Re: lol streams
« on: March 04, 2010, 09:19:37 PM »
Could you implement those operators for char *s?
string operator+(string str,char *str2)
 {
 return str+const_cast<const char*>(str2);
 }

?

550
Tips, Tutorials, Examples / Re: lol streams
« on: March 04, 2010, 07:23:09 PM »
Those functions are on cplusplus.com:
http://cplusplus.com/reference/string/operator+/
http://cplusplus.com/reference/string/operators/
I was looking at <cstring>; for whatever reason, it didn't occur to me to look at <string>.

551
Tips, Tutorials, Examples / Re: lol streams
« on: March 04, 2010, 06:52:23 PM »
I hate it when cplusplus.com doesn't provide an accurate reference.

I learned something new, today, I guess.

552
Tips, Tutorials, Examples / Re: lol streams
« on: March 04, 2010, 06:38:54 PM »
Additionally, here's something else that might be useful:
Code: [Select]
// Operators for strings (addition)
string &operator +(string &str1,string &str2)
 {
 string temp=str1;
 return temp+=str2;
 }
string &operator +(string &str1,cstring str2)
 {
 string temp=str1;
 return temp+=str2;
 }

// Operators for strings (comparison)
bool operator ==(string &str1,string &str2)
 {
 string temp=str1;
 return (temp.compare(str2));
 }
bool operator ==(string &str1,cstring str2)
 {
 string temp=str1;
 return (temp.compare(str2));
 }

// Operators for strings (comparison)
bool operator !=(string &str1,string &str2)
 {
 return !(str1==str2);
 }
bool operator !=(string &str1,cstring str2)
 {
 return !(str1==str2);
 }

Simple operators for strings.

553
Announcements / Re: Pride
« on: March 04, 2010, 06:33:57 PM »
To be honest, I've completely forgotten about goto. :/

554
Announcements / Re: Pride
« on: March 04, 2010, 06:09:54 PM »
With that hash, wouldn't "hello" and "herro" be considered two identical strings?  What does it check besides the length and first and last characters?

555
Announcements / Re: Encryption
« on: March 02, 2010, 08:44:22 PM »
most of us could care less about encryption
I think that most of us couldn't care less. If we could care less, we would care at least some.
I think that your statement seems to be in reverse. :P