c++

How do I get the current UTC offset (time zone)?

How do I get the current UTC offset (as in time zone, but just the UTC offset of the current moment)? I need an answer like "+02:00". ...

C++ and Objective-C autorelease problem

Hi, I have three layers, the bottom layer is written in C++ and the other two middle and top layers are both in Objective-C. The C++ layer stores a reference to a class in the middle layer, and the middle layer also stores a reference to a class in the top layer. Upon receiving a request from the middle layer, the bottom layer is resp...

gcc optimizations cause app to fail

I'm having a real strange problem using GCC for ARM with the optimizations turned on. Compiling my C++ application without the optimizations produces an executable that at runtime outputs the expected results. As soon as I turn on the optimizations - that is -O1 - my application fails to produce the expected results. I tried for a cou...

implementation of string class

I'm interested in the implementation of the reverse iterator with rbegin(), rend() and operator++ of the class string, I can't find it in google, how can I do it? thanks in advance for any help or any link ...

Low level Bluetooth Programming in C++

Hi every one! I need a library (or API, ...) to do some low level Bluetooth programming using C++. Any reference or rich link will be great! And i prefer to work in linux based opreration systems... Thanks in advance... :) ...

Volatile classes in C++

I have a question concerning volatile keyword I can't seem to find an answer for. In my app I have data class that is shared as a state buffer between threads, and I need it to be updated regularly from multiple threads. Class looks like this: class CBuffer { //Constructor, destructor, Critical section initialization/destruction ...

cannot access private member declared in class error while instantiating template

My code is as follows template <typename T> class name { public: name() : h_(0){} template <typename U> operator name<U>() { name<U> u; u.h_ = h_; return u; } private: int h_; }; int main(void) { name<int> a; name<double> b = a; return 0; } The error that I get is int name...

ThreadPool and Producer - Consumer pattern design question

I want to implement a Producer - Consumers pattern using a ThreadPool for the Consumers. I will have 1 producer of requests and multiple consumers that will handle the incoming requests. When Implement the consumers using a threadpool my question if I should still have my own Queue for the producer to put requests on and then pass them...

Custom CListCtrl

Hi! I need to create a ListControl in MFC, each row having different number of columns. How can I do this? Thanks Tarun ...

How is Assembly used in the modern day (with C/C++ for example)?

I understand how a computer works on the basic principles, such as, a program can be written in a "high" level language like C#, C and then it's broken down in to object code and then binary for the processor to understand. However, I really want to learn about assembly, and how it's used in modern day applications. I know processors ha...

Looking for library which implements LZW compression/decompression.

I need to learn how to do Lempel–Ziv–Welch compression using pen and paper for my algorithms and data structures class. Unfortunately we have only a couple of examples in our book of how it is done. I'd like to practice compressing and decompressing text using it, but I need to find a way to check if I'm right doing it right or wrong. On...

nested classes in c++

my question is how often do You really use nested classes in Your practice and in which cases? what is the real power of the nested classes, what can't be done without them? P.S. please don't explain what is it, I know it (from technical point of view) ...

Change only parts of a type in a C++ template

Purpose and craziness aside, is there a way to achieve this in C++? template <typename P> void Q void_cast(P Q *p) const { return static_cast<P Q *>(p); } I'm effectively trying to cast a pointer to a void pointer type whilst keeping any const, restrict and other qualifiers (denoted by Q). I was under the impression there was stu...

Generalizing / Refactoring the code

Hi , My code is something like this : if(country == china) { getCNData(); } else { getDefaultDataForallCountries(); } Now I need to add similar logic as CN for some other country say US . The option available to me is to add one more country check in if condition and make it like if(country ==china && country==US){ getCNandUSD...

Can C++ compilers automatically eliminate duplicate code?

Code duplication is usually bad and often quite easy to spot. I suppose that compilers could detect it automatically in easiest cases - they already parse the text and get the intermediate representation that they analyze in various ways - detect suspicious patterns like uninitialized variables, optimize emitted code, etc. I guess they c...

Memory Allocation.

When we 'define' a variable inside a function (not main here), is the memory allocation done at runtime or the loader serves for us?? And what happens when i have : int f() { int a=10; ........ } main() { int i; scanf("%d",&i); while(--i) f(); .......... } Is 'a' in function f() created 'i' t...

Differences between a shared object and an ordinary library in Linux

What are the main differences between binding to a shared object or to an ordinary object? Also how is this possible to share some variables between some programs and knowing that our variables are never changed by another program? ...

Do I have to use ->Release()?

I am working with a webbrowser host on c++, I managed to sink event and I am running this void on DISPID_DOCUMENTCOMPLETE: void DocumentComplete(LPDISPATCH pDisp, VARIANT *url) { READYSTATE rState; iBrowser->get_ReadyState(&rState); if(rState == READYSTATE_COMPLETE) { HRESULT hr; IDispatch *pHtmlDoc = N...

Ambiguous declarations

What is the difference between the following two declarations: 1. int foo(int); 2. int foo(int()); I am not sure if both the declarations are equivalent. What makes (2) different from (1)? ...

SVD implementation C++

Who can recoment stable and correct implementation SVD method in C++? Preferably standalone implementation (would not want to add large library for one method). I use OpenCV... but openCV SVD return different decomposition(!) for single matrix. I understand, that exists more than one decomposition of simple matrix... but why openCV do l...