c++

./ changes target when i use OpenFileDialog

I'm using a streamwriter to log errors the way it has been designed (please dont ask why) is to open a new streamwriter everytime the application has to log a message. It outputs everything to ./Logs/[current-date].txt which usually resolves to "c:\myappfolder\logs[current-date].txt" Everything works correctly, but after I use an open ...

Understanding memory management in mingw/g++.

Greetings. I was give an assignment to basically explain thi. I have taken a quick look at the compiler documentation, and it seems to be a good place to start although it is quite extensive and I don't have much time. I'd like to know if I'd need to understand the C99 standards beforehand, or if there's another good source I can check....

How to SetFocus to a CButton so that the border and focus dotted line are visible?

I created a simple dialog-based application, and in the default CDialog added three buttons (by drag-and-dropping them) using the Visual Studio editor. The default OK and Cancel buttons are there too. I want to set the focus to button 1 when I click button 3. I set the property Flat to true in the properties for muy buttons. I coded...

Event-driven simulation class

I am working through some of the exercises in The C++ Programming Language by Bjarne Stroustrup. I am confused by problem 11 at the end of Chapter 12: (*5) Design and implement a library for writing event-driven simulations. Hint: <task.h>. ... An object of class task should be able to save its state and to have that state restored s...

C# in comparison to C++: what is your strongest pain?

Here are my points to start with. I cannot guarantee that my structs are initialized with my default constructor. I cannot define a simple " == " operator overload on an interface. I cannot return const objects, which destroys encapsulation. I cannot define a simple generic Sum function because of operator + not working on generic type...

When and why will an OS initialise memory to 0xCD, 0xDD, etc. on malloc/free/new/delete?

I know that the OS will sometimes initialise memory with certain patterns such as 0xCD and 0xDD. What I want to know is when and why this happens. When Is this specific to the compiler used? Do malloc/new and free/delete work in the same way with regard to this? Is it platform specific? Will it occur on other operating systems, suc...

How can I break the reading this text file (using ifstream)? C++

Hi, I wanna stop the reading of my text input file when the word "synonyms" appears. I'm using ifstream and I don't know how to break the loop. I tried using a stringstream "synonyms" but it ended up junking my bst. I included the complete project files below in case you wanna avoid typing. Important part: for(;;) /*here, I wanna b...

How to debug COM object in Visual Studio 6.0 that is created in an ASP page?

I have an old C++ COM component which has to stay in Visual Studio 6.0 format. I can't for the life of me figure out how to debug the code in the actual COM component. I'm able to build it in debug mode, add breakpoints and attach it to the dllhost.exe process, but the Visual Studio environment will only show me the disassembly from dl...

Why can't I have a non-integral static const member in a class?

I noticed C++ will not compile the following: class No_Good { static double const d = 1.0; }; However it will happily allow a variation where the double is changed to an int, unsigned, or any integral type: class Happy_Times { static unsigned const u = 1; }; My solution was to alter it to read: class Now_Good { static double...

C/C++ comparison syntax

Hi all, I noticed for a while now the following syntax in some of our code: if( NULL == var){ //... } or if( 0 == var){ //... } and similar things. Can someone please explain why did the person who wrote this choose this notation? (instead of the common var == 0 way) Is it a matter of style, or does it somehow affect perfor...

What's the best way to write a Windows client app other than .NET?

I'm trying to evaluate whether I should make the .NET Framework a requirement for my new Windows app. I believe .NET is the best and most efficient way to write Windows client apps, so it comes down to how painful the next best alternative is. Specifically, I'm trying to avoid the installation of the .NET Client Profile, which downloads ...

Reference Counting in C++

Hello. I'm implementing a math library in C++. The library will be compiled to a DLL so those who use it will only need the header files the classes' definitions. The users of my classes will be people who are new to the language. However, there are some objects that might be referenced in several parts of their programs. Since I don't ...

Combining two PDF files in C++

In C++ I'm generating a PDF report with libHaru. I'm looking for someway to append two pages from an existing PDF file to the end of my report. Is there any free way to do that? Thanks. ...

C++ const_cast usage instead of C-style casts

Why is the following?: const int i0 = 5; //int i1 = const_cast<int>(i0); // compilation error int i2 = (int)i0; // okay int i3 = 5; //const int i4 = const_cast<const int>(i3); // compilation error const int i5 = (const int)i3; // okay ...

debug c++ program in linux

I have written simple C++ program like this: #include <iostream> using namespace std; int main() { cout << "Hello."; return 0; } now I want to debug it. so what will be the command for it so my control goes to every line. Plz help me. ...

Create modified HFONT from HFONT

I using the Win32 API and C/C++. I have a HFONT and want to use it to create a new HFONT. The new font should use the exact same font metrics except that it should be bold. Something like: HFONT CreateBoldFont(HFONT hFont) { LOGFONT lf; GetLogicalFont(hFont, &lf); lf.lfWeight = FW_BOLD; return CreateFontIndirect(&lf); } ...

Managed C++ Web reference to WCF service problems

Hi, I deveploped a simple WCF service called CLSAPIService that it's Contract contains a method named UpdateLastOpenCloseCall: [OperationContract(Name = "UpdateLastOpenCloseCall", Action = "http://uniform.com/UpdateLastOpenCloseCall")] CallResult UpdateLastOpenCloseCall(int iSwitchID, int iAgentID, string strExtension, BusinessD...

Quadtree vs Red-Black tree for a game in C++?

Hi everyone, I have been looking for a quadtree/quadtree node implementation on the net for ages. There is some basic stuff but nothing that I would be able to really use it a game. My purpose is to store objects in a game for processing things such as collision detection. I am not 100% certain that a quadtree is the best data structure...

Why is ++i considered an l-value, but i++ is not?

Why is ++i is l-value? and i++ not Initially there were 2 questions one was removed since that was exact duplicate. So don't down vote the answers that were answering difference between pre- and post-increment. ...

openGL into png

I'm trying to convert an openGL [edit: "card that I drew"(?):) thx unwind]containing a lot of textures (nothing moving) into one PNG file that I can use in another part of the framework I'm working with. Is there a C++ library that does that? thanks! ...