powell0

Member
  • Content count

    28
  • Joined

  • Last visited

Community Reputation

808 Good

About powell0

  • Rank
    Member

Personal Information

  • Interests
    Programming
  1. If you use a std::set as your data structure then it will fail when you try to add a second element with the same distance because a std::set expects unique elements. While it may be tempting to use a std::set because it gives you an ordering like a priority queue it isn't the same thing because a priory queue can have multiple items with the same priority. Dijkstra's algorithm doesn't have a restriction that all costs must be unique. You'll need to pick a different data structure as your priority queue. I typically use a std::vector and the heap functions (std::make_heap, std::push_heap, and std::pop_heap) to implement a priority queue for Dijkstra's algorithm.
  2. If both classes are still in separate namespaces then you can refer to them by prefixing them with the namespace: Gui::Window Core::Window
  3. Science Fiction Book Recommendations

    I recommend Vernor Vinge. All of his stuff is pretty hard sci fi. The Peace War, Marooned in Realtime, A Fire Upon the Deep, and A Deepness in the Sky all have politic machinations in them to various degrees. The Peace War and Marooned in Realtime are set in the same universe although not directly connected. The same is true of A Fire Upon the Deep and A Deepness in the Sky.
  4. Relational Data Model (C++)

    When I hear "each table will internally be represented by a linked list of rows" I think of what you describe in #2. But that doesn't mean you couldn't also implement #1 along with it. I don't know if you've learned about templates yet, but you could create a templated Table class that holds all of the common table/row manipulation functionality and have the template parameter be the type of data to store in the row. Or you could you create a Row base class and use inheritance to handle common functionality. Either of those would be a combination of your two ideas. From the problem description you posted it sounds like your professor isn't looking for a specific approach so I would go with what makes sense to you based on what you have learned about C++ so far.
  5. C++ Job Interview Books

    The book [url="http://www.wrox.com/WileyCDA/WroxTitle/Programming-Interviews-Exposed-Secrets-to-Landing-Your-Next-Job-3rd-Edition.productCd-047012167X.html"]"Programming Interviews Exposed"[/url] covers the kind of programming problems that software companies ask. It isn't specific to C++ or game studios but it gets into the algorithmic thinking that's necessary. I've found it helpful to review before going in to interviews.
  6. What is going wrong?

    The Fibonacci sequence starts with two 1s. So the first ten terms are: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 *Edit: Never mind. I missed the "sum of even terms" part. Reading comprehension fail.
  7. You can avoid using the preprocessor by using the ternary operator like this: [code] enum { ONE_A, TWO_A, NUM_A }; enum { ONE_B, NUM_B }; const int MAX = (NUM_A > NUM_ ? NUM_A : NUM_B; [/code] Then at least your code is typesafe. Just make sure to comment very clearly and thoroughly what exactly you are doing here and why.
  8. standard library

    I use [url="http://cplusplus.com/"]http://cplusplus.com/[/url] when I need to reference C++ library functions. They tend to have simple examples for most functions.
  9. C++ HELP PLEEEAAAASSSEEEE

    Also, the arguments you pass to your sumGrades function doesn't match the prototype.
  10. C++ function error [Solved]

    By declaring your function as void test(int, int) you are telling the compiler that your function does not have a return value. You need to change the void to an int.
  11. Cue Class Question

    Reference types only need to be initialized with the new keyword if you are creating a new instance. In the code you posted, the cue variable points to an already created Cue object. For example, Cue a = new Cue(); // allocate a Cue object Cue b = new Cue(); // allocate a second Cue object Cue c = a; // Create a reference to an existing Cue object The variables a and c both reference the same Cue object.
  12. Based on my experience* as an undergrad Electrical Engineer you don't really need any programming experience. Knowing Assembly and possibly C is helpful for the microprocessor courses but they'll probably cover the basics there anyway. * Your school's curriculum may vary.
  13. Visual C++ 2008 Complier Problems With Strings

    strings are defined in the std namespace so you need to declare them as std::string
  14. Infinite loop

    Omitting curly brackets means only the next statement is executed inside the loop. So while (i < 100) i++; is the same as while (i < 100) { i++; } but while (i < 100) i++; j++; is the same as while (i < 100) { i++; } j++;
  15. Infinite loop

    The problem is that C++ uses curly brackets to contain multiple statements, not indentation. So the compiler is running this while (BallHolder.size() < 4) truth = false; which is why you have an infinite loop. You really want your code to be while (BallHolder.size() < 4) { truth = false; while (truth == false) { truth = true; BallHolder.push_back(Ball()); iter2 = BallHolder.end() - 1; for (vector <Ball>::iterator iter = BallHolder.begin(); iter < BallHolder.end() - 1; iter++) //ball should not test distance against itself { if ( Distance( (*iter2).Pos(), playerBall.Pos()) <= 30 && Distance ( (*iter2).Pos(), (*iter).Pos() ) <= 30 ) { BallHolder.pop_back(); truth = false; } } } }