c++

Why Does This Pointer-Pointer Initialization Seg Fault?

I create a pointer-to-pointer of a class object and when I try to create a new object using the pointers it seg-faults. Why does this happen? struct Level { int SoldierCount; Soldier **soldier; int taskCount; int *taskPercentage; int *taskBitmapX; int *taskBitmapY; }level; void createM...

Recommendations on TAPI components for MS Windows

Hi, can anyone recommend a TAPI component for use with C++ in the MS Windows environment? I have tried the standard MS implementations of TAPI 2 and 3 and had problems with both. Mainly recovery from modems been switched off or losing connections. The latest problem is the TAPI device disappearing after a couple of days of working perfec...

HOT(Heap On Top) Queues

Could anyone point me to an example implementation of a HOT Queue or give some pointers on how to approach implementing one? ...

Why can't I get a decent function browser in Visual Studio 2008?

There is no way to list the functions in a C++ solution for me... I have a class browser but that isn't helpful since this project has no classes. I need a simple list of all the functions in a c++ file and then just double click one to jump to its source (as a side pane, NOT as a dropdown)... I have to be missing something here as I hav...

C++; refactoring the class

I have a class A which implements many functions. Class A is very stable. Now I have a new feature requirement, some of whose functionality matches that implemented by A. I cannot directly inherit my new class from class A, as that would bring lot of redundancy into my new class. So, should i duplicate the common code in both the c...

Are these appropriate practices when working with std::map?

I have some questions on using std::map: Is using an enum as the key in std::map a good practice? Consider the following code: enum Shape{ Circle, Rectangle }; int main(int argc, char* argv[]) { std::map strMap; // strMap.insert(Shape::Circle,"Circle"); // This will not compile strMap[Shape::Circle] = "Circle"; ...

How do I create a GUI for a windows application using C++?

I am deciding on how to develop a GUI for a small c++/win32 api project (working Visual Studio C++ 2008). The project will only need a few components to start off the main process so it will be very light weight (just 1 button and a text box pretty much...). My question is this: I don't have experience developing GUIs on windows but I c...

How to reset a class using placment delete/new from a template?

I have a pool manager template class. When a class object gets added back to the pool manager I would like to reset it back to it's initial state. I would like to call the placment destructor and placment constructor on it so it gets fully reset for the next time it is given out by the pool manager. I've tried many ways to get this to wo...

How do you create a static template member function that performs actions on a template class?

I'm trying to create a generic function that removes duplicates from an std::vector. Since I don't want to create a function for each vector type, I want to make this a template function that can accept vectors of any type. Here is what I have: //foo.h Class Foo { template<typename T> static void RemoveVectorDuplicates(std::vector<T...

Querying Exchange 2007 storage group/database details with Unmanaged C++

I have a program that's already in C++ which needs to query some information from Exchange 2007. What little information exists in Active Directory (or the Cluster Database) seems to be incorrectly documented, and while there are hints that parts of the information are in the registry, not all of the information we need is available. I ...

vector and dumping

From what i know a vector is guaranteed to be continuous and i can write a chunk of memory to it and do send of fwrite with it. All i need to do is make sure i call .resize() to force it to be the min length i need then i can use it as a normal char array? would this code be correct v.resize(numOfElements); v.clear(); //so i wont get nu...

transform_iterator compile problem

HI, I don't like posting compile problems, but I really can't figure this one out. Using this code: #include <map> #include <boost/iterator/transform_iterator.hpp> using namespace std; template <typename K, typename V> struct get_value { const V& operator ()(std::pair<K, V> const& p) { return p.second; } }; class test { type...

Library Recommendation: C++ HTML Parser

Preferably a light weight HTML parser, not exactly creating a browser or looking to modulate JS or any http connections. ...

what is the C++/CLI syntax to subscribe for events?

I'm updating some old Managed C++ code with lines like this: instanceOfEventSource->add_OnMyEvent( new EventSource::MyEventHandlerDelegate(this, MyEventHandlerMethod) ); where EventSource is the class that publishes events instanceOfEventSource is an instance of that class EventSource::MyEventHandlerDelegate is the delegate typ...

Code Dependency documentation software

I am looking for a tool to document legacy source code for an embedded C project I work with. I had it in my mind that there was a tool that would create charts of the various C and .h files, but I can't recall what it is called. Does anyone know of such a tool? ...

Best c++ container to strip items away from?

I have a list of files (stored as c style strings) that I will be performing a search on and I will remove those files that do not match my parameters. What is the best container to use for this purpose? I'm thinking Set as of now. Note the list of files will never be larger than when it is initialized. I'll only be deleting from the con...

hostname not translated into an IP address using Winsock

Question: The getaddrinfo() does not translate a hostname into an IP address and consequently does not connect() to server. Is something wrong with my implementation - compiles with no warning messages? EDIT: Is this function call to connect correct? ... connect(client, result->ai_addr, result->ai_addrlen) ... Full implementa...

There are Strings in C++?

I have been learning C++ with some books from school that are from the 80's and I'm not really sure if they are strings in C++ or just really long arrays of type char. Can anyone help? ...

LoaderLock error on program termination

I have recently integrated the .NET NLog logging component into one of our applications which developed purely in unmanaged code (C++ and VB6 components compiled in Visual Studio 6). We have a bunch of C++ application talking to NLog via a COM interface. Everything is working fine at the moment but I do notice that the following message...

Returning a reference from a constant function

#include "iostream" #include "vector" class ABC { }; class VecTest { std::vector<ABC> vec; public: std::vector<ABC> & getVec() const { //Here it errors out return vec; } }; Removing the const fixes it , is it not the case that getVec is a constant method. So why is this not allowed? ...