c++

how to differentiate critical windows updates among all updates in c++

how to differentiate critical windows updates among all updates in c++ ...

Prevent memory fragmentation

Hey, Can anyone point me to a source or outline how the algorithm for the low-fragmentation heap works? Thanks in advance ...

Why can one specify the size of an array in a function parameter?

I don't understand why the following example compiles and works: void printValues(int nums[3], int length) { for(int i = 0; i < length; i++) std::cout << nums[i] << " "; std::cout << '\n'; } It seems that the size of 3 is completely ignored but putting an invalid size results in a compile error. What is going on here?...

Error loading type library/DLL

When I use the following code I get an compilation error #import <dwmapi.lib> #include <dwmapi.h> I get the following error: fatal error C1083: Cannot open type library file: 'c:\program files\microsoft sdks\windows\v7.0a\lib\dwmapi.lib': Error loading type library/DLL. Intellisense says: 2 IntelliSense: cannot open ...

how to grow a dynamic array of char pointers (in C++)?

I am trying to work with an array of char pointers. Let's say I dynamically declare such an array like so: int numrows=100; char** array = new char*[numrows]; And then I populate it by using getline to get strings from a file, converting the strings to char arrays, then setting a pointer in my array to point to said char array l...

Reading file with cyrillic

Hi guys, I have to open file with cyrillic symbols. I've encoded file into utf8. Here is example: en: Couldn't your family afford a costume for you   ru: Не ваша семья позволить себе костюм для вас How do I open file: ifstream readFile(fileData.c_str()); while (!readFile.eof()) { std::getline(readFile, buffer); ... } T...

gdb Input/Output error remote debugging to Android

I'm trying to debug an android app that call native code to do some GL rendering. The native code is existing code that I'm trying to port (and that I don't really know that well). I've got the existing code compiling, linking, and installing correctly, and I've got some native functions that call in to that code that are being correct...

Converting from MFC dialog units to pixels

Using C#, how would I convert from dialog units (used in resource files to specify height/width) to pixels? ...

easing c++ to objective-c/cocoa bridging via metaprogramming?

In a pure C++ world we can generate interfacing or glue code between different components or interfaces at compile time, using a combination of template-based compile-time and runtime-techniques (to e.g. mostly automatically marshall to/from calls using legacy types). When having to interface C++ applications with Objective-C/Cocoa fo...

Fully specialised templates and dllexport

Hello, Microsoft says: “Templates cannot be used with functions declared with __declspec (dllimport) or __declspec (dllexport).” (link). What does this mean? Can I export a function which has a fully specialized template class reference as an argument? ...

Writing a C++ version of the algebra game 24

I am trying to write a C++ program that works like the game 24. For those who don't know how it is played, basically you try to find any way that 4 numbers can total 24 through the four algebraic operators of +, -, /, *, and parenthesis. As an example, say someone inputs 2,3,1,5 ((2+3)*5) - 1 = 24 It was relatively simple to code the...

Wrapping a pure virtual method with arguments using Boost::Python.

I'm currently trying to expose a c++ Interface (pure virtual class) to Python using Boost::Python. The c++ interface is: Agent.hpp #include "Tab.hpp" class Agent { virtual void start(const Tab& t) = 0; virtual void stop() = 0; }; And, by reading the "official" tutorial, I managed to write and build the next Python wrapper: A...

debugging loop c++ undefined variable, what type? Hoglund

Hi, I have been reading one of the Hoglund titles and I though, reading great, but can I make it work? Why do they provide non-working examples in books? #include "stdafx.h" #include <cstdio> #include <windows.h> #include <winbase.h> #include <tlhelp32.h> int _tmain(int argc, _TCHAR* argv[]) { HANDLE hProcess; DEBUG_EVENT dbg...

C++ figure out CPU/Memory usage

I have a C++ app called ./blah (to which I have the source code) when I run ./blah I can run "top" and see how much memory & cpu "./blah" is using. Now, is there anyway for "./blah" to access that information itself? I.e. when I run ./blah, I want it to every second dump out it's CPU & Memory usage. What library should I be using to d...

How do I install hardware driver using C++ on Win32?

How do I install a hardware driver (inf file) using C++? Platform : Win32 ...

Why can I not define a member function in a class if that function is to be linked from another translation unit?

I am a bit of a newbie in C++, but I just stumbled on the following. If I have these files: myclass.hpp: class myclass { public: myclass(); void barf(); }; mymain.cpp: #include "myclass.hpp" int main() { myclass m; m.barf(); return 0; } And I use this implementation of myclass: myclassA.cpp: #include <iostream> usi...

Qt create game host

I have been creating a 2D game in Qt and I want to allow others to connect to hosted games to play. Would I just make a "server" in the game and allow others to connect to it? ...

Struct with the function parameters

Can I suppose that, from the call stack point view, it's the same to call a function like function1 int function1(T1 t1, T2 t2); than to another like function2? struct parameters_t { Wide<T1>::type t1; Wide<T2>::type t2; } int function2(parameters_t p); Where, Wide template wide T to the processor word length. For example...

Some problem using pointers to enter a string.

Hi all , I'm a beginner and i need to ask a question.. I wrote this small code that accepts a string from the user and prints it..very simple. #include <iostream> using namespace std; int main() { int i; char *p = new char[1]; for(i = 0 ; *(p+i) ; i++) *(p+i) = getchar(); *(p+i) = 0; for(i = 0 ; *(p+i) ; i++) ...

Invalid use of incomplete type on g++

I have two classes that depend on each other: class Foo; //forward declaration template <typename T> class Bar { public: Foo* foo_ptr; void DoSomething() { foo_ptr->DoSomething(); } }; class Foo { public: Bar<Foo>* bar_ptr; void DoSomething() { bar_ptr->DoSomething(); } }; When I compile it in...