c++

facebook api over rest getting Incorrect signature <error_code> 104

Hello all im trying to send rest api Users.getLoggedInUser i have all the secret session and all the Authenticationi made according to this site : http://wiki.developers.facebook.com/index.php/Authorization_and_Authentication_for_Desktop_Applications here is my code (cpp QT but it can be any thing else ) : QString toAPISignature = ...

Do console apps run faster than GUI apps?

I am relatively new to world of programming. I have a few performance questions: Do console apps run faster than apps with a graphical user interface? Are languages like C and Pascal faster than object oriented languages like C++ and Delphi? I know language speed depends more on compiler than on language itself, but do compilers for pr...

Dynamically allocated structure and casting.

Let's say I have a first structure like this: typedef struct { int ivalue; char cvalue; } Foo; And a second one: typedef struct { int ivalue; char cvalue; unsigned char some_data_block[0xFF]; } Bar; Now let's say I do the following: Foo *pfoo; Bar *pbar; pbar = new Bar; pfoo = (Foo *)pbar; delete pfoo; ...

will a call to std::vector.clear() also set the std::vector.reserve() to zero?

If I use .reserve(items) on a vector, the vector will allocate enough memory for my guess of the number of items that I'll need. If I later on use .clear(), will that just clear the vector or save my earlier defined reserve? thanks. ...

Move million records from MEMORY table to MYISAM table.

Hi, I am looking for a fast way to move records from a MEMORY table to MYISAM table. MEMORY table has around 0.5 million records. Both tables have exactly the same structure (same number of columns, data types etc.). But the MYISAM table is indexed (B-TREE) on a few columns. There are around 25 columns most of which are unsigned intege...

something about C++ unnamed namespace.

#include <iostream> namespace { int a=1; } int a=2,b=3; int main(void) { std::cout<<::a<<::b; return 0; } I complie it with my g++,but the output is 23, who can explain it? is that a way to get access to the <unnamed> namespace ::a? ...

C++ Templates: implicit conversion, no matching function for call to ctor

template<class T> class test { public: test() { } test(T& e) { } }; int main() { test<double> d(4.3); return 0; } Compiled using g++ 4.4.1 with the following errors: g++ test.cpp -Wall -o test.exe test.cpp: In function 'int main()': test.cpp:18: error: no matching functi...

What does: throw 0 do/mean? Is it "bad"?

Context I came across some code, like this: if( Some_Condition ) throw 0; I googled a bit, and found a few other code snippets using that odd looking throw 0 form. I presume one would catch this as: catch(const int& e) { } Or is this a NULL ptr? to be caught as void* ? Question What does this throw 0 do? Is it special in som...

Counting texels using a fragment shader

Hi, I have two textures generated using a fragment shader. I want to be able to count the number of texels in each texture that are above some colour intensity. My question is how can this be done? My initial thought is to count these texels using the fragment shader before generating the texture. However, this would require some sort of...

C++: get const or non-const reference type from trait

I am writing a functor F which takes function of type void (*func)(T) and func's argument arg. template<typename T> void F(void (*func)(T), WhatTypeHere? arg) { func(arg); } Then functor F calls func with arg. I would like F not to copy arg, just to pass it as reference. But then I cannot simply write "void F(void (*func)(T), T&)"...

delete & new in c++

Hi This may be very simple question,But please help me. i wanted to know what exactly happens when i call new & delete , For example in below code char * ptr=new char [10]; delete [] ptr; call to new returns me memory address. Does it allocate exact 10 bytes on heap, Where information about size is stored.When i call delete on same...

How do I force my std::map to deallocate memory used?

I'm using a std::map, and I can't seem to free the memory back to the OS. It looks like, int main(){ aMap m; while(keepGoing){ while(fillUpMap){ //populate m } doWhatIwantWithMap(m); m.clear();//doesnt free memory back to OS //flush some buffered values into map for next iteration flushIntoMap(m); ...

GTK+-based graph?

I want to be able to make a line graph using GTK+ but I'm unsure how to approach this. Has anyone got any hints or tips? ...

Parallel computing for integrals

I want to reduce the calculation time for a time-consuming integral by splitting the integration range. I'm using C++, Windows, and a quad-core Intel i7 CPU. How can I split it into 4 parallel computations? ...

Returning the size of available virtual memory at run-time in C++

In C++ is there a predefined library function that will return the size of RAM currently available on a computer a program is being run on, at run-time? For instance, if an object is 4bytes, then can we divide the available virtual memory by 4 bytes to give an estimate of how many more objects could be stored by the program safely? I h...

C++ template and pointers

I have a problem with a template and pointers ( I think ). Below is the part of my code: /* ItemCollection.h */ #ifndef ITEMCOLLECTION_H #define ITEMCOLLECTION_H #include <cstddef> using namespace std; template <class T> class ItemCollection { public: // constructor //destructor void insertItem( const ...

How to use Boost in Visual Studio 2010

What is a good step by step explanation on how to use BOOST in an empty project in Visual Studio 2010. ...

How to make a 3D UI for an application ?

I'm building an application and I'd like its User Interface to be 3D, most probably a cylinder. The user would see the cylinder[Horizontally laid] and the cylinder's curved surface would have the buttons and any other controls that need to be placed. The cylinder needs to rotate and later, I'd like to add some other effects to the cylin...

Are there any pitfalls when calling functions from a C library in a C++ program?

I'm using a library which has both a C interface and a C++ interface in my C++ program. The C++ one is a bit immature and I must stick with the C one. I was wondering, in more general terms, is there anything specific to keep in mind when mixing C-style binary object files with a C++ project? ...

BeforeNavigate2 does not return URL parameters

I have a C++ program that display a browser using the Microsoft WebBrowser control. I pass hints in the URL parameters to the code so that alternative actions can be taken rather then simply allowing the browser to navigate to the new page. For example, I might pass the URL "WRITE.EXE?RUN" to indicate that I want to run the executable i...