c++

Porting 32 bit C++ code to 64 bit - is it worth it? Why?

I am aware of some the obvious gains of the x64 architecture (higher addressable RAM addresses, ect)... but: What if my program has no real need to run in native 64 bit mode. Should I port it anyway? Are there any foreseeable deadlines for ending 32 bit support? Would my application run faster / better / more secure as native x64 code?...

Linux runtime linker error

Hi All - I'm working though the First Steps tutorial on the POCO Project site, and I've successfully built the library (Debian Linux, 2.6.26, gcc 4.3.2) under my home directory ~/Development/POCO with the shared libraries located in ~/Development/POCO/lib/Linux/x86_64/lib My problem is that any application I build that depends on t...

What's going on with overriding and overloading here in C++?

This doesn't work: class Foo { public: virtual int A(int); virtual int A(int,int); }; class Bar : public Foo { public: virtual int A(int); }; Bar b; int main() { b.A(0,0); } It seems that by overriding Foo::A(int) with Bar::A(int) I have somehow hidden Foo::A(int,int). If I add a Bar::A(int,int) things work. Does any...

Casting to an object with pointers

I have a class, Fixture, that I want to cast to a 3rd party library class, b2FixtureDef. Currently, my function looks like this: Fixture::operator b2FixtureDef() const { b2FixtureDef fd; fd.density = m_density; fd.friction = m_friction; fd.isSensor = m_isSensor; fd.restitution = m_restitution; fd.shape = &b2Poly...

segmentation fault while inserting into priority queue

My definition of priority queue is: template<typename Node, typename Cmp = std::less<Node> > struct deref_compare : std::binary_function<Node*,Node*,bool> { deref_compare(Cmp const& cmp = Cmp()) : cmp(cmp) {} bool operator()(Node* a, Node* b) const { return (a->getfValue()> b->getfValue()); } private: Cmp c...

C++ STL - iterate through everything in a sequence

I have a sequence, e.g std::vector< Foo > someVariable; and I want a loop which iterates through everything in it. I could do this: for (int i=0;i<someVariable.size();i++) { blah(someVariable[i].x,someVariable[i].y); woop(someVariable[i].z); } or I could do this: for (std::vector< Foo >::iterator i=someVariable.begin(); i...

building objects from xml file at runtime and intializing, in one pass?

I have to parse the XML file and build objects representation based on that, now once I get all these data I create entries in various database for these data objects. I have to do second pass over that for value as in the first pass all I could do is build the assets in various databases. and in second pass I get the values for all the ...

Member initialization of a data structure's members

I just ran into an awkward issue that has an easy fix, but not one that I enjoy doing. In my class's constructor I'm initializing the data members of a data member. Here is some code: class Button { private: // The attributes of the button SDL_Rect box; // The part of the button sprite sheet that will be shown SDL_Rect*...

p2p communication using winsock

I am trying to achieve peer to peer communication using winsock but gethostbyaddr always return me NULL ,this thing works only on localhost, server_name is destination ip address server_name="<--ipaddress-->" struct sockaddr_in server; addr = inet_addr(server_name); cout<<"inet_addr(server_name) "<<addr<<endl; hp = gethostbyaddr((char...

Python interpreter as a c++ class

I am working on embedding python in to c++. In some peculiar case I require two separate instances of the interpreter in same thread. Can I wrap Python interpreter in to a c++ class and get services from two or more class instances? ...

C++ Collection of instances implementing a pure virtual class

Hello, I am working in cross platform C++, and have some classes defined like so: (heavily simplified for this example) class ExampleBase { public: ExampleBase( int blah ) : blah_test(blah) { } virtual void DoSomething( ) = 0; private: int blah_test; }; class ExampleImplementer : public ExampleBase { public: ExampleIm...

How do you get how much memory a program uses?

I have two programs, one in C++, the other in assembler. I want to compare how much memory they use when running respectively. How can I do this? I am doing the testing on Windows, but I also would like to know how to do it on Linux. ...

How i can, on some global keystroke, paste some text to current active application in linux with Python or C++

I want to write app, which will work like a daemon and on some global keystroke paste some text to current active application (text editor, browser, jabber client) I think i will need to use some low level xserver api. How i can do this with Python or C++ ? ...

CEdit control MFC, placing cursor to end of string after SetWindowText

Hi, I am using VC9, I've a CEdit control whose contents are reset to default test (say - "fill-in") at the click of a button and then i call SetFocus for the CEdit control. The problem is that the cursor blinks at the start of the default text, and i want it to blink an the end of the default string. How can this be done? ...

How do I enable the SSE/SSE2 instruction set in Visual Studio 2008 (using CMake)?

In Visual Studio 2005 I went in: View --> Property Pages --> C/C++ --> Code Generation --> Enable Enhanced Instruction Set But in Visual Studio 2008? Thanks in advance ...

Is there a non-java, cross platform way to launch the associated application for a certain file type?

First, I found a couple of java specific questions and answers for this. I am looking for more "native", but cross platform solution, using C, C++, some kind of shell scripts, or, in my case, Qt. So the question is, are there standard, cross platform, ways to programmatically open the associated application for certain file types. Or a...

How can I make my char buffer more performant?

I have to read a lot of data into: vector<char> A 3rd party library reads this data in many turns. In each turn it calls my callback function whose signature is like this: CallbackFun ( int CBMsgFileItemID, unsigned long CBtag, void* CBuserInfo, int CBdataSize, void* CBdataBuffe...

Destructor for Singleton

Question : Should i write destructor for a singleton which has program scope (comes alive when program starts and dies when program ends) Detail : i am in a dilemma on "shall i write destructor for a singleton class or not ?" 1) This class has program scope 2) Class uses a lot of memory on heap, So releasing that will take time...

Where Does SYMBOL TABLE Reside?

Hi, I wanted to know where does SYMBOL TABLE reside. Is it in .obj files or an .exe file? Thanks in advance. ...

Socket program Python vs C++ (Winsock)..

I have python program which works perfectly for internet chatting. But program built on similar sockets in C++ do not work over internet. Python program import thread import socket class p2p: def __init__(self): socket.setdefaulttimeout(50) self.port = 3000 #Destination IP HERE self.peerId = '59.95.18.156' ...