c++

My Cross Compiler Always Compiles the Same File

I'm testing to make sure that my cross compiler is working. When I compile hello world it seems to compile fine but when I change hello.cpp to the same program that loops 1000 times the elf file generated is exactly the same size. No matter what changes I make the file is always the same size and as far as I can tell, has the same cont...

Error w/ C++ poco and HTTPSStreamFactory

I am trying to build a C++ app to access a XML resource. Using http the code works fine, from what I can tell from the docs, all I need to do to for the https to work is to make sure ssl is install (yes the dev edition is installed), and change the StreamFactory to HTTPSStreamFactory. Here is the code that works : Poco::Net::HTTPStream...

What language should i learn after PHP/JS ?

i have about 5 years of work in PHP/JS/CSS and other web technologies , as web developer , i feel i should move to learn another languages , other things , but there is huge stack of languages and technologies today : JAVA/( Modern JAVA frameworks ) , C/C++ , Python , Ruby/ROR , Perl , Mobile development ...etc , and this make me confus...

Storing map's first element to a vector in the most generic form. Best solution

My goal is to store all the keys of a map (first item) to a vector and I'm doing the following. template < class vecDet> class storeInto { public: storeInto(vecDet& source) : VectorInfo(source) { } ~storeInto(); template <class pairdet> void operator()(pairdet& pairinfo) { VectorInfo.push_back(pairinfo.first); } p...

How to use KDTree to make top-k query and range query on arbitrary dimensions

Hi, I have used KD-tree(libkdtree++) to store a multi-dimensional data set, and the requirements here is this data set can support top-k/range queries on different dimensions. For example, a KDTree<3, Point> tree: to find the top 100 points whose have highest Point[1](y axis) values. From the implementation of libkdtree++, what's sim...

__typeof -identifier not found

For some reason I keep getting error C3861: '__typeof': identifier not found when I compile my program! I'm including the following libraries: <iostream> <stdlib> <stdio> Any ideas? thanks Edit: More example User.h class User{} main.cpp void f(User* p) { . . . __typeof(p) ... . . . . } ...

removing duplicates from a c++ list

Hi. I have been looking for an effective solution to remove duplicates from a C++ list. The list consists of pointers to a class object which has an attribute ID. I want to remove duplicates based on that ID. for my purpose, the unique method of the STL list will work in which we can pass a BinaryPredicate. i.e. void unique( BinPred p...

How is this 3D rendering on the desktop done

I read a topic on OpenGL.org where a guy made this: http://coreytabaka.com/programming/cube-demo/ He said to release the source code but he never did, does anyone how I could get the same idea? Has to do with clearing the window with alpha but drawing on it as well.. just don't get how to get OpenGL setup like that. From there I can do...

Function template in a namespace in a separate file compiles fine, but the linker cannot find it

This problem is in defining and declaring a function template in a namespace that is defined in an external file from where the function is instantiated. Here's the smallest reproducible example I could come up with. 4 files follow: The function template declaration in a named namespace: // bar.h #include <algorithm> namespace barspac...

Do templates support variable numbers of parameters

Hello, I'm trying to determine if the following scenario is appropriate for a template, and if so how it would be done. I have a base class, event_base. It is inherited by specific types of events. class event_base_c { //... members common to all events ... // serialize the class for transmision virtual std::string ser...

What is an lvalue reference to function?

In §14.1.4, the new C++0x standard describes the non-types allowed as template parameters. 4) A non-type template-parameter shall have one of the following (optionally cv-qualified) types: integral or enumeration type, pointer to object or pointer to function, lvalue reference to object or lvalue reference to function, ...

c++ - How to serialize an object to send over network

I'm trying to serialize objects to send over network through a socket using only STL. I'm not finding a way to keep objects' structure to be deserialized in the other host. I tried converting to string, to char* and I've spent a long time search tutorial, posts in internet and until now I found nothing. Is there a way to do it only with...

problem with casting float -> double in C when fread

I have a problem with casting from float to double when fread; fread(doublePointer,sizeofFloat,500,f); if i change double pointer to float pointer, it works just fine. However,i need it to be double pointer for laster on, and i thought when i write from small data type (float)to bigger data type(double)'s memory, it should be fine. ...

what is the equivalent to passing by address in c#

void Afunction(int* outvar) { if(outvar) *outvar = 1337; } note the qualities: it allows you to optionally pass a variable by reference, so that it can be set by the function. my closest guess would be (ref int? outvar) but that produces ref (int?) NOT (ref int)? which is what I need this functionality is hardly a scarc...

Why are "out of source" builds not the default?

I just found out recently that you can configure Visual Studio (but this question is the same for any compiler) to dump the intermediate .o files into a separate folder outside of the source tree, instead of alongside each individual project. That makes it easy to clean the project up to archive to zip or something along those lines. Wh...

C++ Portability between Windows and Linux

I have a question about writing programs to be portable between windows and linux. Recently I have realized that if you write a program that uses any sort of external library, if that library doesn't have a linux version (or a windows version when developing in linux) then you're screwed. Here then is my question: if I write a program ...

Simple multithreaded server in C++?

I want to write a simple server application that will take commands from a client application and run those commands in separate threads. I was looking at the server class in dlib. Does anyone have experience using this? How does it compare to using Boost's Asio? Example of server in dlib Examples of client/server in Boost Asio ...

What is the current best IDE for C++?

Yes, I know this question has been asked before, but they were answered two years ago (2008). Who's the current (2010) leader? Has Eclipse or Netbeans caught up to Visual Studio since then, or is Microsoft still the hated champion? ...

How to make QDialogButtonBox NOT close its parent QDialog?

I have a QDialog with a QDialogButtonBox widget, and I've connected the button box's accepted signal to a slot in my QDialog subclass, like so: void MyDialog::on_buttonBox_accepted() { QString errorString = this->inputErrorString(); if (errorString.isEmpty()) { // Do work here // code code code... th...

Why base class destructor (virtual) is called when a derived class object is deleted?

A difference between a destructor (of course also the constructor) and other member functions is that, if a regular member function has a body at the derived class, only the version at Derived class gets executed. Whereas in case of destructors, both derived as well as base class versions get executed? It will be great to know what exac...