c++

Small example on getting Cairo graphics to work with MFC?

I have some legacy MFC apps, and I'd like to use the Cairo drawing engine to add some charts and graphs. I'm searching for a small example of how to get that to work. Basically, once I've created a PNG or GIF file, how do I get that show up in an MFC CView window? My google-fu is not finding any good clues. ...

Sizeof array passed as parameter

Given the following program #include <iostream> using namespace std; void foo( char a[100] ) { cout << "foo() " << sizeof( a ) << endl; } int main() { char bar[100] = { 0 }; cout << "main() " << sizeof( bar ) << endl; foo( bar ); return 0; } outputs main() 100 foo() 4 The questions: Why is the array passed as a point...

How to hash and compare a pointer-to-member-function ?

How can i hash (std::tr1::hash or boost::hash) a c++ pointer-to-member-function? Example: I have several bool (Class::*functionPointer)() (not static) that point to several diferent methods of the class Class and i need to hash those pointer-to-member-function. How can i do that? Also how can i compare (std::less) those member funct...

Getting information from Windows Media p.

Can i get the file name of the current playing track/video from windows media player? It will be a small program, written in c++. I have some experience in c++ but no knowledge about this kind of problem. It would be great to show me a way to learn, to start building something ...

Include problems when using CMake with Gnu on Qt project

Hi, I am starting a multiplatform (Win Xp, Linux) qt project. I want to use an out of source build so my directory structure is as followed: project/ CMakeLists.txt (global CMake file, includes other CMakeLists) build/ (my build directory) libA/ CMakeLists.txt mystuff/ subprojectA/ CMakeLists.txt s...

Vectored exception handler and Microsoft C runtime error handling

Hi, I've recently implemented some vectored exception handling to catch errors in our software. This is especially useful as we've just converted from vc6 to vs2005. We're encountering a few problems with the use of the STL library (generally people doing things they shouldn't). I'm trying to catch these errors with my vectored exceptio...

QTableView - not allow user to edit cell

I created a QTableView with a QSqlTableModel. By standard, double-clicking on the cells will mark them and the user can edit them. I want, that the user isn't allowed to do that. He is allowed to mark the whole row by clicking on a single cell, but not to edit the cell. How can I do that? ...

Is there a way to typedef this?

Simplified version of the code: Foo.h: class Foo { private: class Bar { // ... }; typedef std::map<int, Bar> mapType; mapType _map; public: void method(mapType::iterator it); }; Foo.cpp: void Foo::method(mapType::iterator it) { // ... notMethod(it); } void notMetho...

custom stream manipulator for class

Hello All, I am trying to write a simple audit class that takes input via operator << and writes the audit after receiving a custom manipulator like this: class CAudit { public: //needs to be templated CAudit& operator << ( LPCSTR data ) { audittext << data; return *this; } //attempted manipulator s...

How to extend listControl class in C++ and add new functions ?

Hi I need to extend the CListControl class in C++/MFC, which will add several new features in the list control, Any one have good sample code ? Or could you please tell me how can i start it ? Thanks in advance! Or just write the new features and listControl into a ActiveX or COM ?? Which is better ? ...

How to write an unsigned short int literal?

42 as unsigned int is well defined as "42U". unsigned int foo = 42U; // yeah! How can I write "23" so that it is clear it is an unsigned short int? unsigned short bar = 23; // booh! not clear! EDIT so that the meaning of the question is more clear: template <class T> void doSomething(T) { std::cout << "unknown type" << std::...

iterating through TWO sparse matrices

I'm using boost sparse matrices holding bool's and trying to write a comparison function for storing them in a map. It is a very simple comparison function. Basically, the idea is to look at the matrix as a binary number (after being flattened into a vector) and sorting based on the value of that number. This can be accomplished in this ...

The behavior of overlapped vector::insert.

Where does the C++ standard declare that the pair of iterators passed to std::vector::insert must not overlap the original sequence? Edit: To elaborate, I'm pretty sure that the standard does not require the standard library to handle situations like this: std::vector<int> v(10); std::vector<int>::iterator first = v.begin() + 5; std::v...

Is it legal C++ to use a typedef in a method declaration but the canonical type in the method definition?

The GNU C++ (g++ -pedantic -Wall) accepts this: typedef int MyInt; class Test { public: MyInt foo(); void bar(MyInt baz); }; int Test::foo() { return 10; } void Test::bar(int baz) { } int main(void) { Test t; t.bar(t.foo()); return 0; } Is it legal C++? Are other compilers likely to accept it? ...

Circular reference in C++ without pointers

Hi, Is there a way to define circular references without using pointers? I need to have somthing like this: struct A; struct B { A a; }; struct A { B b; }; Thanks! ...

how to pass a stl vector to a function which takes a const [] (c++)

i have a 3d stl vector, vector<vector<vector<double> > > mdata; i also have a function myfun(const double ya[]); to be more precise, it's a function from the GNU Scientific Library, gsl_spline_init(gsl_spline * spline, const double xa[], const double ya[], size_t size); but this is not related to my problem. so now i want to pa...

arrays and functions

my assignment requires me to write a function that reads in a title and return the corresponding fee to the calling function. if the title is not in the list, return -1.0. as per my previous question, im a noob on c++, and this is what i have got at the moment: struct eventType { string title; double fees; }; eventType even...

Optimizing Sockets in Symbian

Hi I have a TCP connection opened between Symbian and a Server machine and I would like to transfer huge chunks of data (around 32K) between these two endpoints. Unfortuantely, the performance figures are pretty poor and I am looking for ideas how I could improve my implementation. One of the things I tried was to increase the number of...

Use a C++ file in Cocoa iPhone App

Hi, I'm trying to use the functionality of the example iPhone app AQOfflineRenderTest in my app (this app specifically isn't important, I just thought it worth mentioning). I have a C++ file with method called: void DoAQOfflineRender(CFURLRef sourceURL, CFURLRef destinationURL) I'm trying to call this from my Cocoa Objective-C c...

Determine whether a class has a function

Using a trick (described by Olivier Langlois), I can determine whether a class has a type defined: template<typename T> struct hasType { template<typename C> static char test( typename C::Type ); template<typename C> static char* test(...); enum{ Value= sizeof(test<T>(0))==1 }; }; I can also determine whether a class has a...