c++

Recursive type casting

I got a typical 'vector4' class with an operator float* to autocast it for gl*4fv as well as []. There's also 'const' version for optimizations for the compiler as well as const refrences, and this works fine: typedef struct vec4 { ... // ----------------------------------------------------------------- // // Cast operator, for []...

Using stringstream in place of string? - C++

I've been given a homework assignment to write a program in C++, but we're not allowed to use the string class. However, we are allowed to use the iostream library, including stringstream. I was thinking of using stringstream where I would have used string for building my classes, returning from functions, etc. Does this sound like a go...

Simulating movement of a window and have it react to collisions

I was reading this topic and I decided to give it a shot. To my astonishment it really seemed easier than what I am making it I guess. I have some confusion about the "DesiredPos" variable. Well at least in my implementation. I am trying to move a window around constantly and have it react like a ball when it hits the monitors edges. Lik...

How can I use a C++ class from Perl?

I have a set of classes written in C++. What would be best way to call them from a Perl script? Thanks. ...

how to find the location of the executable in C

Is there a way in C/C++ to find the location (full path) of the current executed program (the problem with argv[0] is that it does not give the full path). Thanks. ...

std::sort without functors

I have a question regarding the std::sort algorithm. Here is my test code: struct MyTest { int m_first; int m_second; MyTest(int first = 0, int second = 0) : m_first(first), m_second(second) { } }; int main(int argc,char *argv[]) { std::vector<MyTest> myVec; for(int i = 0; i < 10; ++i) { myVec.pus...

Good URLs for tracking implementation progress of C++0x in MSVC and GCC

Does anyone know good URLs/Sites/mailing lists to track the current implementation progress of C++0x features in MSVC and GCC? BTW: Yes I know there is boost but because I'm also very interested in the new language features I only want to know the progress in MSVC and GCC (as those are the two compilers we use for our projects). ...

Supporting different monitor resolutions

I have a MFC application with some bitmaps, dialog boxes and menus. Currently it supports only one monitor resolution (1280x1024). I am planning to add different monitor resolution support to it. To do that I guess I have to load different resolution bitmaps, change the font size etc. My question is, how these are handled in a typical wi...

What type to use for integers larger than 2^32 in C++?

I have an integer variable, that can get a value larger than 4294967295. What type should I use for it (long long, or double, or something else)? ...

How to get into image manipulation programming ?

Hello all how can i do simple thing like manipulate image programmatically ? ( with c++ i guess .. ) jpgs/png/gif ..... ...

C++ inline functions using GCC - why the CALL?

I have been testing inline function calls in C++. Thread model: win32 gcc version 4.3.3 (4.3.3-tdm-1 mingw32) Stroustrup in The C++ Programming language wirtes: The inline specifier is a hint to the compiler that it should attempt to generate code [...] inline rather than laying down the code for the function once and then calling...

Port from gcc 3.3.3 to 4.1.0, C++ templates, undefined reference to

Our application makes use of C++ templates in a number of places. I am currently attempting to port from gcc 3.3.3 to 4.1.0 and am encountering issues. I have recreated the problem in a small shared library and executable. I am building the share library Ok, but the executable fails to link with the following: undefined reference to...

Can Bison parse UTF-8 characters?

I'm trying to make a Bison parser to handle UTF-8 characters. I don't want the parser to actually interpret the Unicode character values, but I want it to parse the UTF-8 string as a sequence of bytes. Right now, Bison generates the following code which is problematic: if (yychar <= YYEOF) { yychar = yytoken = YYEOF; ...

how to get filenames from folder in C++

suppose I want to write ls or dir. how do I get the list of files in a given directory? something equivalent of .NET's Directory.GetFiles, and additional information. not sure about the string syntax, but: string[] filePaths = Directory.GetFiles(@"c:\MyDir\"); ...

$stdin compatibility with std::istream using swig, C++, and Ruby

I have a function in C++ that takes in an std::istream as the input: class Foo { Foo(std::istream &); } Using SWIG, I've bound it to Ruby, but Ruby's $stdin variable is fundamentally different from anything like the stream classes in C++, so I'm not sure how to either 1) expose the C++ class to Ruby in a way that I can use $stdin,...

Photoshop plugin options dialog UI

Im writting a fileformat plugin for photoshop and I need to popup a window with options on load and save such as checkboxes comboboxes etc, how would I do this? ...

JNI Calls different in C vs C++?

Hey Folks, So i have the following code in C that utilizes Java Native Interface however i would like to convert this to C++ but am not sure how. #include <jni.h> #include <stdio.h> #include "InstanceMethodCall.h" JNIEXPORT void JNICALL Java_InstanceMethodCall_nativeMethod(JNIEnv *env, jobject obj) { jclass cls = (*env)->G...

Possible to call C++ code from C#?

Hi, is it possible to call C++ code, possibly compiled as a code library file (.dll), from within a .NET language such as C#? Specifically, C++ code such as the RakNet networking library Would really appreciate it if anyone could give me some pointers on how to do this/point me in the general direction to get started doing this and I ...

[C++] Simulate holding down a key

Im using: keybd_event(0x41, 0, 0, 0); 0x41 is a 'a'. But that just prints one 'a' to the screen. I need it to hold down the key. And when i call keybd_event(0x41, 0, KEYEVENTF_KEYUP, 0); it must release the key. Is that possible? ...

What are the right includes for using the boost accumulators library?

I'm trying to compile this example But that one header isn't enough and I've already spent half an hour trying to clobber all of the errors. Why aren't the required includes specified? I did this: #include <boost/accumulators/statistics/weighted_p_square_cumulative_distribution.hpp> #include <vector> #include <boost/accumulators/accu...