c++

C++: Pointer to data member address doubt.

Hi I have read(Inside C++ object model) that address of pointer to data member in C++ is the offset of data member plus 1? I am trying this on VC++ 2005 but i am not getting exact offset values. For example: Class X{ public: int a; int b; int c; } void x(){ printf("Offsets of a=%d, b=%d, c=%d",&X::a,&X::b,&X:...

Why isn't main defined `main(int argc, std::vector<std::string> argv)` ?

This question is only half tongue-in-cheek. I sometimes dream of a world without naked arrays or c strings. If you're using c++, shouldn't the preferred definition of main be something like: int main(int argc, std::vector<std::string> argv) ? Edit: Even better: int main(std::vector<std::string> argv) There are already multiple d...

What is the interface that change the cpu frequency and the core voltage on the windows platform?

I want to find the interface supplied by windows to change the CPU frequency and core voltage. Thanks! ...

correct usage of GetClipRgn?

I want to write a function that needs to set the clipping region on a DC but restore any existing clipping region on the DC when it is done. So I found GetClipRgn http://msdn.microsoft.com/en-us/library/dd144866(v=VS.85).aspx which sounds like exactly what I want but seems confusing. I couldn't find any examples of using it and Petzold...

Gettext wrong default language

I'm using gettext to handle translations on a C++ project of mine. I generate the .pot file using xgettext and then I create .po files for spanish and english using msginit (en.po and es.po) . The problem is that, although the locale on my system is set to spanish, the .po file that gets automatically filled is en.po, where it should b...

iOS 4 VOIP app responding in the background

Hi there, I have an iPhone VOIP app that copes with multi-multi transmit and receive (ie teleconferencing) set up using BSD sockets. I would like it to be able to respond to incoming requests when it is in the background but from what I can understand of the iOS 4 docs I can only do this on an NSStream object (or CFRead/WriteStream) by...

c++ return private array

hi, i've a class and there is an array set as private, how do i make the get_array() function i mean how do i return that array knowing that i will have to return a pointer of arr[0] as we know , but isn't this breaking the private rule ? is there other way of returning array ? I actually thought of having array2 in the main , then edit...

IMemAllocator:GetBuffer hangs

Does anybody know any reasons why IMemAllocator:GetBuffer (Directshow) hangs, apart from all samples being in use? I have a directshow application which uses GMFBridge by Geraint Davies to connect two graphs. The GMFBridge is used to be able to switch inputs, but I am not switching in this situation. The application captures audio and v...

Jobs related to programming languages

This is more of a directional question. I've been taking computer science classes for about 2 years(a graduate with my A.S. degree this fall) and I'm sort of wondering everyones opinion on where the market is headed towards today with programming languages. I'm getting better with c++ but I still have a lot to learn and I'm pretty knowle...

How to get BS_DEFPUSHBUTTON to work?

My button has these styles: WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON it creates and lights up properly, but in my edit control, when i press ENTER, it does nothing! Heres the styles of my edit control: WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | WS_TABSTOP I am not using a dialog, i have created my windows using CreateW...

Makefile and QTCreator

I am new to programming under linux and not familiar with makefiles since MSVC-Express hides such things very well. But now i wanted to play with some code I found, but it won't compile in qtcreator. But with the makefile in the package i can successfully compile and use it. So all dependencies (libraries and headerfiles) must be correct...

Eclipse Make Error 127

Hey, this is my first time using Eclipse, and my first time programming in a linux environment. So I might end up posting some semi-usless information, but I'm just trying to give what ever details I can. The Issue: I'm trying to build a project, and I'm getting the following errors and warnings. The Question: What would I have to do, ...

[C++] Expected constant expression fails miserably in switch statement..

Say I have a class "Code" defined like this, with a user specified type conversion to int: class Code { public: int code; std::string description; Code (const int c, const std::string& d) : code(c), description(d) { ; } operator int() const { return code; } }; And a second class "Master" using the code class: cl...

How to convert a MQseries reason code to string?

How do i convert/lookup a reason code of IBM Websphere MQseries to its explanation (for logging etc)? ...

template template total specialization

A template template specification is like this: template < template < class > class T > struct MyTemplate { }; How Im supposed to create a total (or parcial) specialization for this template? Is this possible? ...

Passing Template parameters

I am trying to understand templates better I have a template class that starts like this in my .h: template <class DOC_POLICY, class PRINT_POLICY, class UNDO_POLICY> class CP_EXPORT CP_Application : public CP_Application_Imp Now I need to initialize so in my .cpp so I do: CPLAT::CP_DocumentPolicy_None * d = new CPLAT::CP_DocumentPol...

Wrapping linked lists in iterators

A set of APIs that I commonly use follow a linked-list pattern: struct SomeObject { const char* some_value; const char* some_other_value; SomeObject* next; } LONG GetObjectList( SomeObject** list ); void FreeObjectList( SomeObject* list ); This API is not mine and I cannot change it. So, I'd like to encapsulate their...

What does this C++ statement mean?

void max_idxs(vector<int> &pidxs){ vector<fragment *> ids; max_ids(ids); for(size_t i = 0; i < ids.size(); i++){ int weight_idx = ids[i]->weight_idx; //Get weight index } } In this C++ code, what does it mean by int weight_idx = ids[i]->weight_idx;? What does -> mean? Thanks! ...

Eclipse C++ include error: no such file or directory

I've loaded a C++ project into Eclipse (Europa) and I'm familiarizing myself with the CDT interface. There is one particularly annoying error message for the following line: #include "somedir/somefile.h" somedir/somefile.h: No such file or directory The include file exists in "/opt/local/project/include/somedir/somefile.h". Under P...

In C++, how can you avoid explicit downcasts with a map of generic types?

Hey all, This is a little contrived, but say I have a class interface like this: class IResource; class IResourceContainer { public: virtual ~IResourceContainer() {} virtual void AddResource(const std::string& rStrName, std::auto_ptr<IResource> apResource)=0; virtual IResource& GetResource(con...