c++

Should I use structs in C++?

The difference between struct and class is small in C++, basically only that struct members are per default public and class members are per default private. However, I still use structs whenever I need pure data structures, for instance: struct Rectangle { int width; int height; }; I find that very convenient to work with: ...

C++: How to modify a files 'created' timestamp?

I need to modify the 'created' (if exists), 'modified' and 'accessed' timestamps of a file. Ideally this would be a platform-independent solution. I've looked around the boost libraries but I can't see anything relevant. The nearest I've found to something relevant is this for Windows. Can anyone help? Thanks. ...

COM + WaitForSingleObject

I've been trying to find a good architecture for one application for the last few days, and after some research I'm finally stuck, and the reason is COM. The app in question will have multiple GUI threads, and they will schedule work items for worker thread. The worker thread will initialize COM via CoInitialize(NULL);, create few COM c...

Referencing a dll in Java

I need to reference a C++ dll from my Java project. The method that I need to expose is actually written in Visual Basic. Is there any way to access the Visual Basic code in C++, so that it can eventually be accessed in the Java project? ...

help in solving Bus error c++

hey, i am trying to compile a c++ program in Linux, using the command in the shell g++ -Wall *.cpp -o prog and for some reason it keeps on giving me a weird error: g++: Internal error: Bus error (program cc1plus) Please submit a full bug report. See for instructions. i searched the net for this bus error, and it says that it has to d...

Does anybody have any experience with FastDB (C++ in-memory database)?

FastDB is an open-source, in-memory database that's tightly integrated with C++ (it supports a SQL-like query language where tables are classes and rows are objects). Like most IMDBs, it's meant for applications dominated by read access patterns. The algorithms and data structures are optimized for systems that read and write data entire...

(C++) Extending vector iterator to fill my needs.

Hi everoby, I have the following design in one of my projects: template<typename C> class B { int numValue; C inner; } template<typename C> class A { vector<B<C>> container; ... Iterator InsertItem(C item) {...} } What I want is a way to modify the existing vector iterator to return an Iterator which will retu...

Errors with 'this' pointer

I'm having a problem with the this pointer inside of a custom class. My code looks as follows. class Foo(){ public: void bar(); bool baz(); }; bool Foo::baz(){ return true; } void Foo::bar(){ bool is_baz = (*this).baz(); } As I said above, I believe the error I'm getting (LNK2019) is coming from the this. I think it is l...

What is an "operator int" function?

What is the "operator int" function below? What does it do? class INT { int a; public: INT(int ix = 0) { a = ix; } /* Starting here: */ operator int() { return a; } /* End */ INT operator ++(int) { return a++; } }; ...

Segmentation fault using FastDelegate

I've got a problem with my test code. It compiles well, but when I try to call delegate, program crashes. #include "..\libs\FastDelegate\FastDelegate.h" #include <string> #include <map> #include <iostream> typedef fastdelegate::FastDelegate1 <int, int> FuncPtr; struct Function { FuncPtr Ptr; int Param; Function() {}; Function (Fun...

Seg Fault with SOCI

So I haven't been coding in C++ for quite a while now, but I'm pretty sure this issue is related to SOCI and not some general knowledge of memory usage in C++. Here is the problem : I'm using SOCI to query a table and get a field, and the sql statement line always cause a Segmentation Fault. Which is quite troublesome... Here is the code...

What C++ OSS project has good source code to learn from?

Possible Duplicate: Code reading: where can I read great, modern, and well-documented C++ code? Is there an open source project written in C++ that you would in particular recommend for learning purposes? Something I could study and get ideas from about how correct structuring and code design in C++. ...

ALSA: Looping Sound Problem

I have written a small program that tests the ALSA library on an Embedded Linux board. The program configures ALSA, plays a single sound and then waits 1 minute before exiting. Here is what I am observing: after playing the sound, there is silent pause and then the sound is played again. I am 100% positive that the program itself is not...

How to pass structure from C# to ActiveX function created in C++ (MFC)

Hi everyone, I've strange problem: the MFC structure is #define SENSOR_DESC_LEN 30 #define CAM_ID_LEN 20 typedef struct { unsigned int SensorType; char Desc[SENSOR_DESC_LEN]; unsigned int CommType; // USB or TCP - COMM_TYPE float FirmwareVersion; float HardwareVersion; int Width; int ...

c / c++ disable access to files

Is it possible to disable access of some program to files completely? Because I don't want it to have any kind of access to files on system, is it possible to compile it so it doesn't have access to file stream or to run it someway it cant access files? ...

Linking libpng with g++.

I'm trying to get libpng working on linux. I couldn't get it to work through netbeans, so I ran g++ directly as g++ -lpng -lz main.cpp -o test and it compiles. When I try to run it it it outputs ./test: error while loading shared libraries: libpng14.so.14: cannot open shared object file: No such file or directory. I assume this means I a...

(C++) Using map for inventory system

Is there any practical way to get objects to work with maps? (I don't really know much about maps so sorry if this is a bad question). I'm interested in using a map for an inventory system that will contain item objects. An item object has a name, description, and money value. The key would be the item's name, and the linking variable wo...

What happens to open file handles after an execv call? (C++)

Hi, On Linux, I have some C++ code where I want to execv another application. That program outputs some data to the stderr. I therefore redirect the stderr by calling freopen() with stderr as the stream parameter. The thing is, I want to redirect the stderr for another process that is run. Here is the scenario I am working with. I ...

Modifying command line args so that they cannot be seen in ps output

Hi everyone, I have an executable that accepts certain command line arguments. Any user on the machine can find the arguments by doing a ps (Unix) or procexp (Windows). Some of these arguments are things like passwords. I know we should not be passing in passwords like that. Is there any way in code of the executable that I can change ...

Unit test in VS2010.

Does anyone uses this feature of VS2010 for C++ projects? If yes could this person give some links to tutorials or explain how to do it? ...