c++

Possible memory leak?

Okay, so I have two classes, call them A and B--in that order in the code. Class B instantiates class A as an array, and class B also has an error message char* variable, which class A must set in the event of an error. I created a third class with a pure virtual function to set the errorMessage variable in B, then made B a child of that...

Simple Makefile Problem (with a simple dependency)

Hi all, I have 4 '.cpp' files and 1 header files: Tools.cpp Code1.cpp Code2.cpp Code3.cpp and Tools.hh Now all Code1.cpp, Code2.cpp, Code3.cpp use functions stored in Tools.cpp. Currently, what I do to compile all of them is using this simple shell script: #!/bin/bash echo "compiling Code1.cpp"; g++ Code1.cpp Tools.cpp -o Code1 e...

What's your favorite g++ option?

Hi, I am a newbie in C++ programming. When compiling I never use any option. This is my day to day command: g++ MyCode.cc -o MyCode For safety practice what's the best option to use? ...

Coding Standards

For those of us that have programmed enough I’m sure we have come across many different flavours of coding standards that you can use when it comes to programming. e.g. http://msdn.microsoft.com/en-us/library/ms229042.aspx You might derive your coding standards for the current company you work for or from the original author of the cod...

C++ std::map of template-class values

Hi everyone, I'm attempting to declare a Row and a Column class, with the Row having a private std::map with values pointing to a templated Column. Something like this: template <typename T> class DataType { private: T type; }; template <typename T> class Field { private: T value; DataType<T> value; }; class Row { pri...

Why is memory still accessible after std::map::clear() is called?

Hello, I am observing strange behaviour of std::map::clear(). This method is supposed to call element's destructor when called, however memory is still accessible after call to clear(). For example: struct A { ~A() { x = 0; } int x; }; int main( void ) { std::map< int, A * > my_map; A *a = new A(); a->x = 5; my_map.insert...

Is there any api for getting the value of UseCanonicalName in Apache WebServer?

We need to check the value of UseCanonicalName in httpd.conf in Apache Webserver(any version) from an application using an api. I have googled for it and couldn't find any api related to it. Please help. TIA ...

C++ MSXML2 - Remove Namespace from XML

Hi, I need a nice way to be able to remove all namespace from an XML document in C++. Currently the doc is loaded into a MSXML2::IXMLDOMDocument2Ptr class. Can't currently see any methods that can do this Thanks ...

Boost considered harmful?

Lots of the answers to C++ questions here contain the response: "You should be using boost::(insert your favourite smart pointer here) or even better boost::(insert your favourite mega complex boost type here)" I'm not at all convinced that this is doing any favours to the questioners who, by and large, are obvious C++ novi...

Platform-independent concurrent programming libraries for C++

Hi, I am familiar with concurrent programming in Java which provides a lot of tools for this. However, C++ concurrent programming isn't so easy to start using. What is the best way to start programming concurrently on C++? Are there any nice libraries which wrap concurrent programming primitives and provide you with more high-level con...

smart pointers (boost) explained

What is the difference between the following set of pointer? When do you use each pointer in a production code, if at all? Examples would be appreciated! 1.scoped_ptr 2.shared_ptr 3.weak_ptr 4.intrusive_ptr Edit#1 Do you guys use boost in production code? ...

Using C++, how can I instantiate WinForms form defined in C# library?

Hello, I'm sorry if this question has already been answered but I couldn't find it. I am trying to open a C# form when a function in a C++ program is called (the main program is in C++, the form is in C#, it is an empty form just to try how it works). I am using Visual Studio 2005 and I have both projects in my solution. The C# project ...

What causes Visual Basic Run-time error -2147319765 (8002802b) in Excel when an ActiveX control has been instanced?

I have created an ActiveX control using C++. I use Visual Basic code to instance the control in an Excel worksheet. I can only run the VB script once, subsequent runs cause the following runtime error when attempting to access the 'ActiveSheet' variable: Microsoft Visual Basic Run-time error '-2147319765 (8002802b)': Automation erro...

Best practices for writing the parser

Are there any best practices that I should follow while writing a parser? ...

Checking if a double (or float) is nan in C++

is there an isnan() function? p.s. I'm in mingw (if that makes a difference) UPDATE Thanks for the responses I had this solved by using isnan() form <math.h>, which doesn't exist in <cmath>, which I was #includeing at first. ...

Does using boost pointers change your OO design methodology?

After switching from C++ to C++ w/boost, do you think your OOD skills improved? Do you notice patterns in "Normal" C++ code that you wouldn't consider that you've switched, or do you find that it enables a more abstract design? I guess I'm really wondering if you just use it as a tool, or if you change your entire approach to OO desi...

C++ Eclipse debugger: "Cannot find bounds of current function" and doesn't stop at breakpoints

I am using Ubuntu for one of the first times and eclipse's debugger has given me more trouble than I can deal with. For the moment I just want to try to figure out how to get the "Cannot find bounds of current function" to stop so I can see where my flow of control goes awry. I know this is a vague question, but I'm willing to quickly ...

Why do some devices not enumerate with SetupDiGetDeviceInterfaceDetail()?

I am maintaining an application that uses SetupDiGetDeviceInterfaceDetail() to find out information on the installed serial ports on the computer. I have noticed while testing this that there are some devices, such as my Lucent WinModem, that do not show up in that enumeration. It turns out that I am having a similar issue with a set o...

how do I set the proper initial locale for a C++ program on Windows?

I'm fairly new to localized programming, and I'm trying to figure out how to set the proper initial locale for a newly-launched unmanaged C++ application (from within the app). As far as I can tell, new applications start with the C locale, rather than the proper regional locale (English, German, etc). So what I need to do is call setlo...

How to find an item in a std::vector?

All I wanna do is to check whether an element exists in the vector or not, so I can deal with each case. if ( item_present ) do_this(); else do that(); ...