c++

How can a template function 'know' the size of the array given as template argument?

Hi all, In the C++ code below, the templated Check function gives an output that is not what I would like: it's 1 instead of 3. I suspect that K is mapped to int*, not to int[3] (is that a type?). I would like it to give me the same output than the second (non templated) function, to which I explicitly give the size of the array... Sh...

Create thread with specific privilege c++

hello I have multi-thread application that I want to create a thread with different user privilege (for example : multi domain admin privilege). but I can't find any Win32 API CreateThread to do that. How to create thread with specific user privileges? thanks. ...

c++ multiple enums in one function argument using bitwise or "|"

Hi, I recently came across some functions where you can pass multiple enums like this: myFunction(One | Two); Since I think this is a really elegant way I tried to implement something like that myself: void myFunction(int _a){ switch(_a){ case One: cout<<"!!!!"<<endl; break; case Two: cout<<"?????"<<e...

How to get started with game programming using VC++,C++,DirectX quickly?

Hi I am working in VC++ and I am quite interested in game programming and I have few queries. 1).What one must know before starting game programming ? 2).Can anybody give me info @ resources like tutorial ,links ,etc. which would help me to start as fast as possible ? 3).Also give me info @ some good books on game programming ? Any h...

template class with overridden operators

I want to add a operator override to perform assignments/__set__s inline. Template :- class CBase { public : static void SetupVmeInterface(CVmeInterface *in); protected : static CVmeInterface *pVmeInterface; }; template <class T> class TCVmeAccess : public CBase { public: TCVmeAccess(int address);...

negative color with glBlendFunc() ?

i want my lines to be drawn with negative color (taken from the screen under the line), i just didnt understand how the blending works, looked at docs etc, tested 50 combinations and so on. started to think its not possible at all... could someone just give the two values, im tired of thinking how it works. thanks, ...

C/C++ J2ME interpreter

Hello, do anyone know some C or C++ interpreter for cell phones? I have Nokia 5310 and found some Basic interpreter (CellBasic) and want to develop in C or C++ on the go. Or, does anybody knows Scheme J2ME intepreter? ...

Problem using reinterpret_cast<> in c++

I am trying to cast a datastream into a struct since the datastream consists of fixed-width messages and each message has fulle defined fixed width fields as well. I was planning on creating a struct and then using reinterpret_cast to cast pointer to the datastream to the struct to get the fields. I made some test code and get weird resu...

C/C++/C# Force window to be on top

Is the there a way to force another window to be on top? Not the application's window, but another one, already running on the system. (Windows, C/C++/C#) ...

C++ good coding style - always fully qualify library types?

What is generally considered good coding style in C++ where you use types from the standard library? For example, if I have a using namespace std; directive would you still expect to see library types fully qualified like so: std::string or is it acceptable to just use string as the type identifier? If you do fully qualify, can you expa...

A dynamic buffer type in C++?

I'm not exactly a C++ newbie, but I have had little serious dealings with it in the past, so my knowledge of its facilities is rather sketchy. I'm writing a quick proof-of-concept program in C++ and I need a dynamically sizeable buffer of binary data. That is, I'm going to receive data from a network socket and I don't know how much the...

What does this statement mean? "good C++ programming typically doesn't use pointers in complicated ways."

In this other question in the winning answer I read: ... good C++ programming typically doesn't use pointers in complicated ways. What does it mean to not use pointers in complicated ways? (I'm really hoping that this isn't a subjective question) ...

Size of an array

This question is about C++ I always thought that name of an array in C++ is only a pointer, so I thought that int ar[10]; cout << sizeof(ar); will give me the same as sizeof(int *). But it gives 40 - so it is real size of whole array. It also gives 40 when array size is given by variable: int n = 10; int ar[n] I want to copy a cla...

C/C++/C# SetWindowPos: Window on top of others

I would like someone to give a working example of SetWindowPos on how to make a window "topmost" (be on top and stay there) using either C/C++/C#. Thanks in advance! ...

Anyone ever used boost::singleton together with boost::logger?

i think it makes sense to use boost::singleton together with a boost::logger, so that all the objects in the executable can access the same logger and dump strings to it. class logger_singleton : public boost::mutexed_singleton<logger_singleton> { private boost::logger blogger; public: logger_singleton(boost::restricted);...

How do I keep Eclipse from automatically deleting my exe file

I use Eclipse for Java development. There is an *.exe file in a subdirectory of my workspace, which keeps getting deleted. Specifically, one of the projects is dedicated to C++ development using MSVC; there is no Java there. The root of this project has cpp and h files, and I use MSVC to generate the exe under the /bin directory. A...

SSE2 Compiler Error

I'm trying to break into SSE2 and tried the following example program: #include "stdafx.h" #include <emmintrin.h> int main(int argc, char* argv[]) { __declspec(align(16)) long mul; // multiply variable __declspec(align(16)) int t1[100000]; // temporary variable __declspec(align(16)) int t2[100000]; // temporary variable __m128i mul...

Can you help with creating a zip archive with the LZMA (7zip) SDK?

I am trying to use the LZMA SDK to create a zip archive (either .zip or .7z format). I've downloaded and built the SDK and I just want to use the dll exports to compress or decompress a few files. When I use the LzamCompress method, it returns 0 (SZ_OK) as if it worked correctly. However, after I write the buffer to file and try to open ...

Performance profiling on Linux

What are the best tools for profiling C/C++ applications on *nix? (I'm hoping to profile a server that is a mix of (blocking) file IO, epoll for network and fork()/execv() for some heavy lifting; but general help and more general tools are all also appreciated.) Can you get the big system picture of RAM, CPU, network and disk all in on...

Practical and advanced C++ usage

I've studied C++ as a college course. And I have been working on it for last three years. So I kinda have a fairly good idea what is it about. But I believe to know a language is quite different from using it to full potential. My current job doesn't allow me to explore much. I have seen you guys suggest studying a open source project a...