c++

C++ standard thread class?

I have come across many ad hoc implementations of thread class in C++, but why is there no standard library thread class like the one in Java? The one that I generally use in C++ is http://www.linuxdocs.org/HOWTOs/C++Programming-HOWTO-24.html ...

Re: Help with Boost Grammar

I have redesigned and extended the grammar I asked about earlier as shown below: // BIFAnalyser.cpp : Defines the entry point for the console application. // // /*============================================================================= Copyright (c) Temitope Jos Onunkun 2010 http://www.dcs.kcl.ac.uk/pg/onun/ Use, mod...

Android: Statically link against libstdc++

Hi, my program compiles nicely for Android, however when I try to copy it to the Android emulator, it gives the following error: knight666@Katja-Linux /media/Data/Shared/Galaxians $ acpy Galaxians.android Filename: 'Galaxians.android' 819 KB/s (420657 bytes in 0.501s) link_image[1638]: 825 could not load needed library 'libstdc++.so....

detect if extended desktop is to the left or to the right

So, I have a screen capture utility (it takes full screen shots and saves it to png files) I've written, and it uses SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN to determine the width and height of the desktop. I then get the desktop DC and copy out the bits and save them as png. BitBlt( backDC, 0, 0, backBufferCX, backB...

How to pass non static member function into glutDisplayFunc

Hi All I know this is not a new problem and has been solved, but I still dont know about it :) I have a class which has functionality to initialise opengl and run it in separate thread. My problem is: openGL callbacks such as glutDisplayFunc, glutMotionFunc etc accepts void (*f) void, and I cannot pass class member function. ways ar...

deleting dynamically allocated object that contains vector in C++ STL

I have a class class ChartLine{ protected: vector<Point> line; // points connecting the line CString name; //line name for legend CPen pen; //color, size and style properties of the line }; where Point is a structure struct Point{ CString x; double y; }; In main() I dynamically allocate...

Why are Hexadecimal Prefixed as 0x?

Why are Hexadecimal Prefixed as 0x and not anything else? I understand the usage of prefix but I dont understand the significance of 0x. ...

LDAP c++ API choice

I would like to write my own LDAP client under Linux, specific to our local environment. Most probably I will use QT4 to provide a shiny frontend without much hassle. I found that there seems to be no standard C++ library for this. OpenLDAP provides a C API and there should also be a C++ API (experimental?) somewhere.. Do I need to use...

particle system: particle generation

Hello: I have a system that generates particles from sources and updates their positions. Currently, I have written a program in OpenGL which calls my GenerateParticles(...) and UpdateParticles(...) and displays my output. One functionality that I would like my system to have is being able to generate n particles per second. In my Gener...

staying within boundaries of image?

So I am to loop through copyFrom.pixelData and copy it into pixelData. I realize that I need to check the conditions of i and j, and have them not copy past the boundaries of pixelData[x][y], I need another 2 loops for that? I tried this, but was getting segmentation fault.. Is this the right approach? void Image::insert(int xoff, ...

Design: How to declare a specialized memory handler class

On an embedded type system, I have created a Small Object Allocator that piggy backs on top of a standard memory allocation system. This allocator is a Boost::simple_segregated_storage<> class and it does exactly what I need - O(1) alloc/dealloc time on small objects at the cost of a touch of internal fragmentation. My question is how ...

How can I use the compile time constant __LINE__ in a string?

I can use __LINE__ as a method parameter just fine, but I would like an easy way to use it in a function that uses strings. For instance say I have this: 11 string myTest() 12 { 13 if(!testCondition) 14 return logError("testcondition failed"); 15 } And I want the result of the function to be: "myTest line 14: ...

Returning pointers in a thread-safe way.

Assume I have a thread-safe collection of Things (call it a ThingList), and I want to add the following function. Thing * ThingList::findByName(string name) { return &item[name]; // or something similar.. } But by doing this, I've delegated the responsibility for thread safety to the calling code, which would have to do something li...

PCAP Web Service Usage Logging for Dummies

I've been assigned the task (for work) of working with PCAP for the first time in my life. I've read through the tutorials and have hacked together a real simple capture program which, it turns out, isn't that hard. However, making use of the data is more difficult. My goal is to log incomming and outgoing web service requests. Are t...

How can I work around the fact that in C++, sin(M_PI) is not 0?

In C++, const double Pi = 3.14159265; cout << sin(Pi); // displays: 3.58979e-009 it SHOULD display the number zero I understand this is because Pi is being approximated, but is there any way I can have a value of Pi hardcoded into my program that will return 0 for sin(Pi)? (a different constant maybe?) In c...

templates and casting operators

This code compiles in CodeGear 2009 and Visual Studio 2010 but not gcc. Why? class Foo { public: operator int() const; template <typename T> T get() const { return this->operator T(); } }; Foo::operator int() const { return 5; } The error message is: test.cpp: In member function `T Foo::get() const': test.cpp:6: error:...

Does Microsoft make available the .obj files for its CRT versions to enable whole program optimization on CRT codepaths?

Given the potential performance improvements from LTCG (link time code generation, or whole program optimization), which requires the availability of .obj files, does Microsoft make available the .obj files for the various flavors of its MSVCRT releases? One would think this would be a good place for some potential gain. Not sure what th...

Want to store profiles in Qt, use SQLite or something else?

I want to store some settings for different profiles of what a "task" does. I know in .NET there's a nice ORM is there something like that or an Active Record or whatever? I know writing a bunch of SQL will be fun ...

unmanaged c++ and ADO.NET

I have to rewrite/extend(with features like connection pooling) portions of the database interace code in a multithreaded, enterprise scale legacy c++ applications. The application interacts with both SQL and ORACLE datbases. I was wondring if ADO.NET can be used instead of the current OLEDB / OCI solution. I am hoping to get some feedba...

c++ projects for beginners

So I know this is a frequent question, but I still can't find a good one. It's a 3-week internship where I get to teach high school students. I would cover basic c++ first week, and start the project second week. What I need is a project that is doable (for them) in 2 weeks. It is interesting. Somehow I want it to be interactive (somet...