• Content count

  • Joined

  • Last visited

Community Reputation

174 Neutral

About Photonman

  • Rank
  1. C++

    Well, you could actually make a global function that overloads XOR (^) and change it to become a pow operator. Doing so, I suppose, would be redefining the language (sort of), however, you can't change the precendence of the operator, and XOR is much lower than exponent, so you would always have to use parens to get the precedence to work right. Why you would do this is beyond me. Operator overloading, when used as it was intended, is a language feature that makes syntax easier when working with straightforward operations on custom types. For example, if you had a class for complex numbers, instead of having to call c.add(x); you can overload operator+ so you can do c+a; This leads to cleaner, easier to understand code, assuming the programmer makes sure that what the overloaded operators perform is straightforward. ex) + makes sense when used for string concatenation even though it is directly associated with numbers and not strings, but defining operator+ on some other kind of custom type may make sense to you and you alone. In this capacity, you are simply altering your own types to act more like the concrete types of the language, not the reverse.
  2. Multi Thread Programming ?

    I ran through a lot of problems with trying to learn and implement my first multithreaded programs. In the end, after struggling to get Boost to work, Boost.Thread is what I wound up using. I think that Boost's thread library offers a much clearner, more abstract way to do threading, allowing you to concentrate on the problem at hand instead of figuring out how to make your specific classes and such work with some other lower-level library. There is also a .msi installer for all of Boost (which would have made the job installing Boost a lot easier for me :P) Just go to and follow the download link to get the installer.
  3. Bitwise foolishness

    Well, that worked. Thanks all. C++ does have _rotl() and _rotr(), but they take int types (can't remember, but I think they take long) I guess I thought that using and unsigned char wouldn't matter once it got put in the string which uses plain old char, but I can see how that was a little shortsighted now that I think about it. I know that just rotation isn't much, but I rotate the values and then XOR them with a key. I'm just trying to play with very simple things to throw into the function, and if you have any ideas, they're welcome :)
  4. I'm trying to make a simple encryption algorithm (why? I don't know) that uses a key for XOR encryption on a std::string. I got that algorithm working perfectly (that's now called cipher() in the new version), and decided to add a bitwise rotation on each char in the string before encryption just to throw in a curveball. So what I do is save the highest bit by copying the original value into a char and then ANDing that with 0x80 (128, HOB of char...right?), shift it down to put the high bit in the low position, shift the bits in the original character I'm working on in the string up one, and then OR that value with the char that has the HO bit in it to put it in the low position of the string's char. This, as far as I know, should be a rotation. To undo this, I copy the low order bit into a char like I did with the high order bit, do the opposite shifts, and then OR it again. Obviously, since I'm posting here, you can guess (correctly) that I don't see my original message, just ciphertext. I'm thinking maybe things are getting screwy because of the sign bit or something? Anyway, I call the following functions (something close anyway, I've been playing idly with the code, so I might have made it even worse): void encrypt(string& s, const string& k) { for(register int i=0;i<s.size()-1;i++){ char c=s[i]; c&=0x80; s[i]<<=1; c>>=7; s[i]|=c; } cout<<s<<endl; cipher(s, k); cout<<s<<endl; } void decrypt(string& s, const string& k) { cipher(s, k); cout<<s<<endl; //All output OK up to this point. This decrypts properly. for(register int i=0;i<s.size()-1;i++){ char c=s[i]; c&=0x01; c<<=7; s[i]>>=1; s[i]|=c; } cout<<endl<<s<<endl; } This would be a lot easier if C++ had a rotation operator as well as shift. I think someone propsed it for C++0x. Hope it gets in...
  5. auto_ptr + STL containers

    Well, I can give you Stoustrup's explanation from TC++PL (pg. 368): The purpose of auto_ptr_ref is to implement the destructive copy semantics for ordinary auto_ptrs while making it impossible to copy a const auto_ptr.... ... Note that auto_ptr's destructive copy semantics means that it does not meet the requirements for elements of a standard container or for standard algorithms such as sort(). That really is a good book.
  6. C++ right-justify loop output

    I seem to remember having to do this in my programming class when I learned how to use formatting functions...ahhhh memories. Anyway, assuming you're printing a string, count the number of characters in the string to be printed, subtract that number from the value passed to setw, then pass that number into fill, then print the string.... should work....
  7. C++ Web Programming?

    This is exactly what I am getting at. Now, don't get me wrong, C++ is one of my favorite languages and definitely the one that I use the most, buy why would you want to force C++ to work in a web-based environment? C++ was meant to be about a step and a half above asm- allow the programmer to get very close to the hardware, but allow them to abstract, and let them choose whatever tools they want to use, whether they make the right decisions or not. It was not designed to be a web language, and besides, there are plenty of other languages that are specifically designed for that task. Are these people just using C++ for the sake of using C++, or do they think it will somehow be better?
  8. C++ Web Programming?

    Anyone know about the "C++ Server Pages" by Micronovae? ( They appear to claim that you can write web apps in C++. Could it be true? They don't give a lot of information, and I suspect that it's not all it claims to be.
  9. C++ Workshop - Tutor List

    Hmmm....worth a shot, I guess. Jorden R. Mauro Jorden first learned C/C++ in 2004, and has since devoted most of his time to learning the art of programming. He has studied other languages like Perl, Python, and Java, although he uses C++ for the majority of his projects. He will be attending RIT this year to major in Computer Science, and aims to get into the gaming industry thereafter. He has worked on diverse projects including an attendance program used by his school, several text-based games, and some 2d scrollers.
  10. C++ Workshop - Introduction

    superpig- forgot gamedev already had a channel. heheh As far as compilers go, I have Dev and VC++EE. I like them both, though the fact that VC was made by a pro team with more resources and getting paid shows. However, Dev is a good compiler, supports *most* of the standard (g++ doesn't have the export keyword) and it is, I think, simpler. I would be a lot less intimidated by Dev if I were a beginner. You can compile standalone cpp files without prokects or solutions or any of that other claptrap. I don't think that the choice of compiler will be a massive issue as long as they are standards compliant. As previously mentioned, errors are fairly similar across IDEs. I had some questions about the environment itself when I first used VC, but that was all. I'm glad that we've agreed to be open to this and am sure that we can clear up any IDE confusions in the forum itself. Maybe, as suggested by programwizard, this could be covered in an introductory thread. I'd be willing to write a "getting started" instructions for Dev and VC++
  11. C++ Workshop - Introduction

    corporate darwinism....that's a good way to look at it. I suppose I am being a little paranoid.....people wouldn't be here on gamedev if they weren't motivated. If it might be of use, I can talk to my friend about setting up an IRC channel for us if you'd like...that way we can have a more real-time medium in which to interact....I know that we all live in diverse time zones, but it could still be beneficial. Just let me know if you'd like this set up, and I should be able to get it done.
  12. (thinking in c++) references

    I read this earlier and I thought this was what your problem was....I have the book and didn't remember anything hinkey about the references section. I knew you would figure it out :D
  13. local variable in long loop

    As far as the POD types, you can declare multiple variables in a for loop, whilch will only be available within the scope of that loop according to the new standard. for(int i,j,k=0;k<10;++k){//create once //use i,j, and k here } //but not here Regarding the other stuff, you could also always dynamically allocate them before use in the loop and then delete them afterward......I guess. Not an expert here, just giving it a shot. There could be optimizations made by the compiler, too. Maybe a compiler honcho could clear that up, but I answered part of it, anyway :)
  14. C++ Workshop - Introduction

    I second C++ Essentials as a possible candidate. Though it has no questions it is a good, complete turorial and reference, and a not-too-easy-not-too-tough introduction (any difficulties of which could be offset by the community) Will we be posting a tentative schedule? I think this would be very important for people who are >noob but <intermediate, etc. so that they can determine when to jump in so that they won't be doing things that they already know. However, with that there is the slight possiblity that someone could skip over something thinking that they already know it||don't need it, and later on they find that they should have done what they skipped. That disturbing yet possible possibility brings this question to my mind: are we going to keep track of students? And what about people who just got "hello, world!" to work and want to join in after we've started talking about polymorphism? I think that the open forum idea for posting solutions is very bad. The poor nooblets who struggle with the problems will be able to just come on once somebody has posted an answer and look at how to solve their problems without having to work through it on their own. People need to do the exercises to learn, and I feel that opening up the possiblity of people finding answers like this without working it out one their own will be extremely detrimental. Just things to think about once we decide on a compiler, book, and get the green light from the staff...
  15. C++ Workshop - Introduction

    I couldn't give any recommendation on books, but I'm sure any one of the above would be a good choice. I'm sure that anywhere the book(s) are lacking, the combined knowledge of the instructors will serve to iron things out. As far as compilers, I think that Dev is *much* more beginner friendly. Easy to set up, somewhat more customizable, waaaaay smaller, and the devpaks are idiotproof. Although VC++ EE is a superior compiler. I think that if and when we get a new forum, we should post a giant "start here" sticky with recommendations/links/instructions/tips for compilers, books, online resources, course outline, and perhaps even an "Is programming right for you" article. That should hopefully sort all the applicants and get them ready and primed for the course. Also, as I said, I would really love to teach, although I have little in the way of credentials. I'm only eighteen. I took one high school intro course, and other than that, I'm self taught. All I have to my name is a rather basic 2D videogame I wrote in allegro ( and I read TC++PL...that's about it. I hope that's enough to qualify me :\