# xegoth

Member

242

154 Neutral

• Rank
Member
1. ## Ugh, haven't programmed in C++ in forever, simple vector question.

Quote:Original post by Will F When you insert something into a standard library container, the object is not put into it. Instead a copy of the object is made. Ah, okay. I didn't realize STL makes a copy, the fact that it was passed by reference is what sent me down that path. Thanks.
2. ## Ugh, haven't programmed in C++ in forever, simple vector question.

I've been coding in C# for the last year or so and recently returned to C++ only to find I seem to have forgotten everything. Heh. Anyhow... given the following scenario... class foo { list<std::string> m_list; foo(int Count) { for(int i = 0; i < NumSeats; i++) { string bar = "something"; m_list.push_back(bar); } } }; Okay. What happens to the data in the list? I want to think that the string is in the scope of the for loop, so it goes out of scope each time around, meaning the list is empty. What *really* happens?
3. ## Bullet/Ship Conundrum

My guess is your ship is going faster than 2km/s and your bullets always fire at 2km/s. Remember, if a bullet is being fired out of a moving ship its initial velocity is: shipVelocity + InitialBulletVelocity. This is because the bullet is ALREADY moving inside of the ship at the speed of the ship, before it's fired. Whatever the muzzle velocity is, needs to be added to the ships velocity.
4. ## What operating system do they use at work?

Visual studio .net for development.. Windows OS. Then again, I work at Microsoft. :P
5. ## Binary tree puzzle. Is there an elegant solution?

The node to the right is the node on the same level (depth), but to the right. 1 is connected to 4 is connected to 6. 3 is connected to 9.
6. ## Binary tree puzzle. Is there an elegant solution?

Here's the problem: Create a function that takes a binary tree and connects each node to the node closest to its right. There has to be a really elegant solution for this using recursion... but it hasn't occured to me yet. Anyone?
7. ## Simple OO question.

dbzprogrammer, yeah that's the answer. I just couldn't rememember. Thanks :)
8. ## Simple OO question.

My C++ is unfrotunately a bit rusty and I've run into a problem I don't remember how to get around. If you have the following layout: //A.h #ifndef _A_H_ #define _A_H_ #include "B.h" class A { A() { b = new B(this); } B b; } #endif //B.h #ifndef _B_H_ #define _B_H_ #include "A.h" class B { B(A &a); } #endif The above code wouldn't compile because the line: B(A &a); A hasn't been defined yet. How do you get around a problem like this when you want a class to pass a reference of itself to a child?
9. ## WM_PAINT is sent to parent if its child redrawn?

It looks to me like under normal circumstances the child window gets redrawn when the parent window gets redrawn. This makes some sense as it would be undesirable to redraw the child window only and not the parent. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/pantdraw_2s32.asp

I'm trying to create a class to represent a Win32 dialog in my app. The problem is, the dialog must have a proc which can't be a member of a class. Here's how I implimented it: // Global CConfigMenu *g_ConfigMenu = NULL; // A callback director for the graphics settings dialog's message handler. BOOL CALLBACK ConfigDlgProcDirector( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { return g_ConfigMenu->ConfigDlgProc( hDlg, message, wParam, lParam ); } CConfigMenu::CConfigMenu() : m_pEnumeration( NULL ) { g_ConfigMenu = this; } This is all good and fine unless there is more than one instance of the class. Does anyone know of an elegant way to roll a win32 dialog up into a class? My current way of doing it seems hackish.
11. ## Off center fullscreen

I've seen the same issue and fixed it by switching my game to a higher resolution. I don't know what caused it, for me I wanted to run at a higher resolution anyhow so it didn't matter. You might want to try different resolutions as a temproary solution. (Someone else here may know exactly what causes that).

What about just a fixed image without a loading bar. Do I need to continually redraw it or is once sufficient?

I have a DirectX app that takes a bit of time to load. What I want to do, is display a fullscreen bitmap (think like loading counter strike), while the game loads. I know I have to display my image after DirectX is initialized, but what about rendering it? I won't be in a render loop because I'll be loading my level. Does anyone know of a really good way to impliment a bitmap being displayed at load time? I can think of a few ways to do it but none of them stand out as really clean and effective to me. As far as I'm concerned, I want a simple implimentation that is displayed quickly.
14. ## Enum question.

Quote:Original post by Roboguy IIRC, the first one is invalid. It compiles just fine for me. Does it just have no effect?
15. ## Enum question.

What's the difference between: const enum PlacesILike { Paris, SanDiego, Hawaii } and enum PlacesILike { Paris, SanDiego, Hawaii } I forget what const means in that context. :/