c++

Is there a better way to run a c++ makefile from a c# project?

Hi, I have a project in c# which uses bindings to use some c++ code. The c++ code consists of multiple DLL's which are compiled using a makefile. Currently I'm trying to run the makefile using a pre build event which calls nmake. However to get it to find nmake I need to have a line in it like the following: "$(DevEnvDir)..\..\VC\vcvar...

Breaking cyclic dependency in C++

I have the following cyclic dependency problem I am trying to solve: typedef std::map<int, my_class> my_map; class my_class { ... private: my_map::iterator iter; }; class otherclass{ public: my_map::iterator getIter(); private: my_map map; }; The compiler does not like this, since my_class was not declared before the ty...

C++0x Lambda to function pointer in VS 2010

I am trying to use a lambda to pass in place of a function pointer but VS2010 can't seem to convert it. I have tried using std::function like this and it crashes and I have no idea if I am doing this right! #include <windows.h> #include <conio.h> #include <functional> #include <iostream> #include <concrt.h> void main() { std::f...

Force application to close on Windows CE using C++

How can I force an application, say myapp.exe, to close using C++ on Windows CE from a different application? The scenario is that I have a previous installation of some software that does not behave properly when upgrading to a new version. I therefore need to kill a process (from the updater) before continuing the update. ...

how to connect turbo c/c++ program to database

Hello Friends, I want to connect turbo c or turbo c++ program with any database like MS Access/SQL Server/Oracle/MySQL. If any body know then please tell me and also give source code for it. Thanks, Karandeep Singh ...

Help Integration in Qt/C++ Application

Hi, I am using Qt 4.6 so do C++. I have a User Manual (.chm) for my application which has the help required for the users to run the application. Now I want this help to be integrated into my application, so that when the user selects for help from the application, the user manual will be opened with the corresponding help page displ...

Lagging video display using cvShowImage()

Hello, I'm trying to display a video file at 25fps smoothly without any lag. The code below does this, but only achieves about 10fps, taking about 0.1ms to execute. With cvWaitKey(1) I get around 0.03 to 0.04ms, which would be perfect, but the named window just stays grey and doesn't show the video! Is this because cvShowImage() is to...

Printer settings change at runtime not taken into account in my application...

Hello, I have followed instructions on the msdn to change at runtime a printer paper size configuration in my application. I have replaced the dmOrientation option by the dmPaperSize to meet my need. All seems to execute fine (no error), but my new paper size is not taken into account until I manually validate the paper size from the p...

detecting the memory page size

Is there a portable way to detect (programmatically) the memory page size using C or C++ code ? ...

operations on files in c++

for example we have created file in c++ how to write content in this file and then output on screen? ...

problem with reading program arguments in Visual Studio C++

I'm running C++ program in VS2005, and I've set only one argument in project properties-> debug-> command line args, and it's named profile1.dll for example. here's a code snippet cout<<"number of arguments:" << argc<<endl; for (int i=0; i<argc; i++) cout << "argument " << i << ": " << argv[i] << endl; In the output I get ...

Memory Management + containers

Friends Containers have automatic memory management mechanism . When values are inserted using copy Constructor and when values are removed , destructor is called for each value. After the no of elements are read, what stage desctuctor gets called ? How does a container class handle memory when elements are read not erased ? Many t...

Solve this Error ,while using 'export' keyword in templates?

Program :main.cpp struct X { int x; }; export template <class T> T const& min(T const&, T const&); int main() { return min(2, 3); } x.cpp struct X { int x; }; export template <class T> T const& min(T const &a, T const &b) { return a<b ? a : b; } error:Compiling with gcc export.cpp...

operator== with double dispatch in C++

How should one implement operator==(const Base& base) to compare subclasses s.t. the calls would be properly dispatched when called as Base* base1 = new Derived1(); Base* base2 = new Derived2(); base1->operator==(*base2)? ...

std::vector - Pointer to buffer after reserve()?

I have a std::vector of values for which I know the maximum size, but the actual size will vary during usage: void setupBuffer(const size_t maxSize) { myVector.reserve(maxSize); } void addToBuffer(const Value& v) { myVector.push_back(v); if (myVector.size() == maxSize) { // process data... myVector.clear(); } } Howev...

Boost serialization fails in release mode while working in debug

I am using boost serialization with xml files with a C++ program. When I test my program in debug mode, it is working fine. Then I try with the exact same file in release mode, but my program fails when loading the files. I even tried to generate the xml files with my program in release mode, load them back, and it crashes as well. The...

Drawing a jpg in MFC

Hi, I've been trying to show a jpg image in MFC, but I can't get it drawn. I'm a complete MFC newbie an everything I got up until now is mostly adapted from things I found on the net. Currently I have this: Picture.h: #pragma once #include <afxwin.h> class Picture { public: Picture(); bool load(LPCTSTR filePath); bool draw...

MFC Ribbon - get base element clicked from command

I have a CMFCRibbonUndoButton on the ribbon of an MFC application. I have a handler for when its ID is clicked (ON_COMMAND(ID_EDIT_UNDO, ...)). However, when the button is also in the quick access toolbar (QAT), there are apparently two CMFCRubbonUndoButtons which each keep their own state. In the command handler, I don't know how to ...

how write this code in c++

i have following code uint32 joaat_hash(uchar *key, size_t len) { uint32 hash = 0; size_t i; for (i = 0; i < len; i++) { hash += key[i]; hash += (hash << 10); hash ^= (hash >> 6); } hash += (hash << 3); hash ^= (hash >> 11); hash += (hash << 15); return hash; } what will b...

Resolving a Circular Dependency between Template Classes

I have two classes, Foo<T> and Bar<T>, derived from Base. Each overrides a method virtual Base* convert(ID) const, where ID is an instance of a type that uniquely identifies a particular instantiation of Foo or Bar (pretend it's an enum). The problem is that Foo::convert() needs to be able to return a Bar instance, and likewise Bar::conv...