c++

Play an mp3 on a Pocket PC with VSC++ code

Does anyone know of some mp3 playing code for the pocket PC. I have 3 mp3s that I want to play when my application loads up, depending on how you log in. I've used VS2005 C++ to code what I've got now. I think code to play mp3 for the desk might do the job. But I might not have access to the library, that's why I've been specific. ...

smart pointers + "this" considered harmful?

In a C++ project that uses smart pointers, such as boost::shared_ptr, what is a good design philosophy regarding use of "this"? Consider that: It's dangerous to store the raw pointer contained in any smart pointer for later use. You've given up control of object deletion and trust the smart pointer to do it at the right time. Non-sta...

Safe to use the compiler generated assignment operator?

I'm using the CPoint class from MFC. There is no explicitly defined assignment operator or copy constructor (AFAIK). Yet, this works: CPoint p1(1, 2), p2; p2 = p1; // p2 now is equal to p1 I'm assuming this is working automagically because of a compiler generated assignment operator. Correct? If so, can I be confident that this isn'...

C++ experts: is the offset of a member variable to its class constant under these conditions?

Given a variable foo of type FooClass* and a member variable in that class named bar, is the distance between foo and &(foo->bar) the same in any situation with some constraints: FooClass is a non-POD type. We know that foo will always point to an instance of FooClass, and not some subtype of it. We only care about behaviour under a si...

Destructor question C++

I declared a private variable vector<SomeClass> theVector; someplace inside my SomeClass class. Why can't I say: "delete theVector" inside my SomeClass destructor? The compiler error says: type `class Vector<SomeClass>' argument given to `delete', expected pointer What expected pointer? ...

How do stl containers get deleted?

How does container object like vector in stl get destroyed even though they are created in heap? EDIT If the container holds pointers then how to destroy those pointer objects ...

QX11EmbedContainer and QProcess problem...

Hello folks, I've been trying to put a QX11EmbedContainer in my app, and I need to start a terminal within it (because with konsolepart I can practically do nothing). QX11EmbedContainer* container = new QX11EmbedContainer(this); // with or without "this" I got the same result container->show(); QProcess process(container); QString exec...

What is the best way to implement a cross-platform, multi-threaded server in C/C++?

Part of the development team I work with has been given the challenge of writing a server for integration with our product. We have some low-level sensor devices that provide a C SDK, and we want to share them over a network for use by people collecting data. Sounds simple, right? Someone would connect a sensor device to their machine in...

Is args[0] guaranteed to be the path of execution?

This is a fundamental question, but an important one none the less... When starting a C++ program whose main method has the following common signature: int main(int argc, char* args[]) { //Magic! return 0; } is args[0] always guaranteed to be the path to the currently running program? What about cross platform (since I am in ...

c++ continuous integration with performance metrics

I want to set up a continuous integration and test framework for my open source C++ project. The desired features are: 1. check out the source code 2. run all the unit and other tests 3. run performance tests (these measure the software quality - for example how long does it take the system to complete the test) 4. produce a report base...

Smart pointers for Windows Mobile 6 SDK

I cannot get std::tr1::shared_ptr for my WinMobile project since the STL for WinCE is maintained by a different team at Microsoft :( aarrgh... Anyone worked with another thread-safe, reference counting smart pointers? I'm actually using yasper which seems to be good. Thank you very much. ...

Can't assign a member which is a pointer to a templatized class

My problem is that in my "Widget" class i've the following declaration: MouseEvent* X; In a member function I initialize the pointer with an address the normal way: X = new MouseEvent; Ok, this last line makes the compiler stop at: error C2166: l-value specifies const object All right, a MouseEvent is declared as a typedef t...

C++ Operator Ambiguity

Forgive me, for I am fairly new to C++, but I am having some trouble regarding operator ambiguity. I think it is compiler-specific, for the code compiled on my desktop. However, it fails to compile on my laptop. I think I know what's going wrong, but I don't see an elegant way around it. Please let me know if I am making an obvious mista...

C++ Header files - Confused!

game.h needs: - packet.h - socket.h server.h needs: - socket.h socket.h needs: - game.h The problem comes when I try to include socket.h into game.h, because socket.h has game.h included already. How do I solve these kind of problems? ...

C++ I'm stuck filling this BST with its proper values

Hi, I have created a BST full of WordInfo objects that have a vector to point out which of the other WordInfo objects is a synonym or antonym. Each word is identified by an integer on its source file, dictionary.txt. The BST has received so far its list of words, but I have trouble filling in the synonyms. To put it bluntly, I'm pretty c...

How to make warnings persist in visual studio

Suppose I have files a.cpp and b.cpp and I get warnings in a.cpp and an error in b.cpp. I fix the error in b.cpp and recompile -- since Visual Studio doesn't have to recompile a.cpp, it doesn't remind me of the warnings it found before. I'd like to somehow have the warnings persist; however, I don't want it to treat warnings as errors (...

Problems using EnterCriticalSection

I need to work with array from several threads, so I use CRITICAL SECTION to give it an exclusive access to the data. Here is my template: #include "stdafx.h" #ifndef SHAREDVECTOR_H #define SHAREDVECTOR_H #include <vector> #include <windows.h> template<class T> class SharedVector { std::vector<T> vect; CRITICAL_SECTION cs; ...

Why do you use typedef when declaring an enum in C++ ?

I haven't written any C++ in years and now I'm trying to get back into it. I then ran across this and thought about giving up: typedef enum TokenType { blah1 = 0x00000000, blah2 = 0X01000000, blah3 = 0X02000000 } TokenType; What the heck is this? Why is the typedef keyword used here? Why does the name TokenType appea...

Are there cases where a "finally" construct would be useful in C++?

Bjarne Stroustrup writes in his C++ Style and Technique FAQ, emphasis mine: Because C++ supports an alternative that is almost always better: The "resource acquisition is initialization" technique (TC++PL3 section 14.4). The basic idea is to represent a resource by a local object, so that the local object's destructor will release th...

How do I do lots of processing without gobbling cpu?

I know the question title isn't the best. Let me explain. I do a TON of text processing which converts natural language to xml. These text files get uploaded fairly fast and thrown into a queue. From there they are pulled one-by-one into a background worker that calls our parser (using boost spirit) to transform the text into xml and lo...