c++

overloading the << operator in c++

hey, i got something that i cannot understand ,there are two types of solutions for overloading this operator 1 is including the friend at the start of the method and the other 1 goes without the friend. i would very much like if some1 explain whats the difference between them advantages / disadvantages. for example overloading the opera...

Getting a Virtual Trackball to work from any viewing angle.

Hi, I am currently trying to work on getting my virtual trackball to work from any angle. When I am looking at it from the z axis, it seems to work fine. I hold my mouse down, and move the mouse up... the rotation will move accordingly. Now, if I change my viewing angle / position of my camera and try to move my mouse. The rotation will...

Caching strategies for Windows end-user applications?

I'm working on what is essentially the runtime for a large administrative application. The actual logic that is being executed, as well as the screens being shown and the data operated upon is stored in a central database. In order to improve performance, the runtime keeps data queried from the database in various caches. However, it is...

Running applications against a different SDK in OS X?

Summary I want to run my cross-compiled application against the 10.5 libraries. Is there an environmental variable that allows this to work? Longer version I cross-compiled my OS X C++ application for a 10.5 target, on a 10.6 host. It compiles fine. The compiled application is linked against libraries like /usr/lib/libstdc++.6.dylib. ...

Does using atlbase.h makes my compiled app to have some extra dependencie?

I would like to know if including atlbase.h in my c++ project will make the compiled application to have a dll dependency or something like that. ...

Singletons destructors

Hello, I'm using boost's singletons (boost::serialization::singleton). I have to control the queue of class destructings. One singleton consist of the object whicn uses object from second singleton. And I have to delete second singleton, before the first one. Can I do this? p.s. please, don't say anything about singleton programming tec...

How to make sure iterators do not overpass end() ?

Hi! I have been using advance on some iterators, but I am afraid of a possible leapfrog above end(). I would like to make sure my iterators stay between the bounds, I thought of the distance but it seems it does not return what I would be expecting (non-positive values when iterators overpass end()). How would you make sure there is no ...

Formatting styles in 2-D arrays

for ex: let a 2-D array be 1 2 3 2 3 5 7 8 9 Then the output must be 1 2 3 3 5 9 Using simple for loops i want the syntax. ...

Can someone explain rvalue references with respect to exceptions?

Lets say I've this exception class: struct MyException : public std::exception { MyException(const std::exception &exc) : std::exception(exc) { cout << "lval\n"; } MyException(std::exception &&exc) : std::exception(std::forward<std::exception>(exc)) { cout << "rval\n"; } }; ... ... try { thr...

How to get records from MySQL in c/c++?

This is pretty easy in PHP: $con = mysql_connect("localhost:".$LOCAL_DB_PORT, $LOCAL_DB_USER, $LOCAL_DB_PASS); mysql_select_db("db", $con); mysql_query("set names utf8", $con); $result = mysql_query("select ..."); while($row = mysql_fetch_assoc($result)) { ... } But what's the easiest way to do it with c/c++ in windows? ...

parse number from the string

Say I have the line in this format "word word 12 YR" or "word word 10 MO" and I want to convert it to char * containing either "12Y" or "10M" respectively. The format is two words followed by numerical followed by the word denoting the year or the month. words are space/tab separated. Currently, I am playing around with the s...

template and what is created during compilation

if i have a template function: template<class T, class S> void foo(T t, S s){..//do something//} and then, inside the main i do this: string str = "something"; char* ch = "somthingelse"; double num = 1.5; foo(ch, num); foo(num, ch); foo(str, num); .. my question is in the compilation what code will be written at the executable? is ...

How to use lock_guard when returning protected data

I have a question concerning the use of boost::lock_guard (or similar scoped locks) and using variables that should be protected by the lock in a return statement. How is the order of destroying local objects and copying the return value? How does return value optimization affect this? Example: Data Class::GetData() { boost::lock_...

Should I manipulate a C++ map's value via a pointer or by updating the record?

I'm using a C++ std::map to hold a large collection of entities: using std::map; map {structureEntityID, classEntityRecord} tableEntityRecords; //(replace {}s with arrows) I will be frequently modifying the entities in my table (many times a second). Is it better to modify those records via a pointer or is it better to make a local ...

What are the recommended C++ parallelization libraries for large data processing

Can some one recommend approaches to parallelize in C++, when the data to be acted up on is huge. I have been reading about openMP and Intel's TBB for parallelization in C++, but have not experimented with them yet. Which of these is better for parallel data processing ? Any other libraries/ approaches ? ...

replacing #define

Hi, i want to replace a #define INTERVAL_MASK(b) (1 << (b)) with a inline function. int INTERVAL_MASK(int b) { return (1 << b); } But i have a switch case, which uses the preprocessor directive in case statements. How to go about converting this? Replacing the switch with if is the only option? Thanks, gokul. ...

hpp files && implememtning a class extending vector

hi, i have 2 questions. does any one know what an hpp file is? why would someone do that ? i am trying to implement a class that extends vecotr but i want to use all thee riginal functinos and add on actions for each functin. so i wrote: #include <iostream> #include <vector> #ifndef _MY_PERSONAL_VECTOR #define _MY_PERSONAL_VECTOR ...

Does winbase::LoadLibrary() load .pdbs?

I have issues with debugging of a library loaded at runtime, and an unknown is: Does winbase::LoadLibrary() load the .pdb in debugging mode? Because if it doesn't, that would explain why I cannot use any debugging in my DLL, and if it does, that would at least tell me to search for the problem somewhere else. Obvious follow-up: If it...

integer range in c

why integer has a range between 0 and 32768? ...

Cross-Platform Building, Standard Directory Structures, Environment Variables

I've started using CMake as a build tool for a cross-platform command line program that requires FFTW3 and Boost.Format. I'm familiar with the Unix-like standard directory structures for headers and binaries of installed libraries but I'm wondering what the quasi standard is on Windows platforms as to how and where libraries are installe...