c++

How do I create a string of blanks in C++?

I need to create a string of blanks in c++, where the number of spaces is a variable, so I can't just type it in. How do I do this without looping ? Thanks! ...

Shorter Calls/Names Without Using Defines

Hi, Simple question, how do I shorten a call/name without using defines. For example, I have a singleton that I have to call that is within a namespace (I cannot use using namespace blabla because it is not allowed) like so: MyFW::GameRoot::Instance()->DoSomething(); Now I can assign that to a variable, which works somewhat if I am ...

Modern C++ GUI library for Windows, suggestions?

Hello, First of all I do know that there is already an identical question but that was answered 2 years ago. It can be found here. http://stackoverflow.com/questions/115045/good-c-gui-library-for-windows I have exactly the same question as that guy above. Even my demands from a GUI library are the same as his bullet point. For my proje...

question about second pointers

i am using c++ and i have some trouble about pointers i know that if we declare some variable int t=7; int *p=&t; *p gives adress of variable t but in c++ here also definition of **s why it is used ?i have read it but i have some misunderstanding please can anybody give me example how use?let take about given example ...

Visual Studio compiled Qt Plugin doesn't load in release mode

Hi, I am developing a Qt application and a Qt Plugin library. Everything is working fine as far as I use the debug mode. Nevertheless, when I try to compile in release mode the plugin doesn't load. I got the following error message from QPluginLoader: Expected build key "Windows msvc release full-config" got "Windows msvc debug ful...

C++ get the mangled names of a function/method

Hi I need to determine the mangled name of a function from within an c++ app itself. Is there any equivalent to the __FUNCDNAME__ macro in g++ ? ...

access Error table in msi

Hi All, Basically I am trying to make a localized copy of an existing English msi file. If I rebuild the MSI with proper wxl file n code page it takes a long time, and I need my installer in more than 25 languages. I am able to access all other local strings like text on controls n all but I couldn't find the way to change the error tabl...

What is Single and Double Dispatch ?

Hello to all, i have wrote the visitor pattern as follow but i don't understand what is single and double dispatch. AFAIK, single dispatch is invoke a method based on caller type where double dispatch is invoke a method based on caller type and argument type. I guess double dispatch is happen in single class hierarchy but why visitor ...

The boost "signature" question

I'm trying to figure out how could many boost classes be able to accept a function signature as template argument and then "extract" from there the result type, first argument type and so on. template <class Signature> class myfunction_ptr { Signature* fn_ptr; public: typedef /*something*/ result_type; // How can I define this? ...

Adding Conditionals & Functions to a Math Parser

I have a binary tree based mathematical expression parser I built, which works great for 'normal' math, like: (3.5 * 2) ^ 1 / (1 << 6). however, I would like to expand it a little to add a ternary selection operator, mirroring the one from C: {expr} ? {true-expr} : {false-expr}. I would also like to add functions, like sin(x) or ave(...)...

How to implement final conditions properly?

This is what I'm trying to do (this is a simplification of a real project): int param; int result; void isolated(int p) { param = p; try { // make calculations with "param" and place the // result into "result" process(); } catch (...) { throw "problems.."; } } I can't change the way process() works, since this...

Calling SDL_SetVideoMode several times

Is it ok to do the following? SDL_Surface* screen; screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE | SDL_RESIZABLE | SDL_FULLSCREEN ); screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE | SDL_RESIZABLE ); screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, ...

Using a union for multiple interpretations of IP address?

At work we have the following construct to enable interpreting an IP address as either an array of 4 bytes, or as a 32-bit integer: static const unsigned int IP_V4_LENGTH = 4; union IPv4Data { u_int32 address; u_int8 bytes[IP_V4_LENGTH]; }; This works fine, but I'm a little worried after reading chapter 97 "Don't use unions to...

Is typedef just a string replacement in code or somethings else?

I was curious to know how exactly typedef works. typedef struct example identifier; identifier x; In above statement is 'identifier' just replaced (somethings like string replacement) with 'struct example' in code? If no, what does typedef do here? please enlighten! ...

C++ read from istream until newline (but not whitespace)

I have a std::istream which refers to matrix data, something like: 0.0 1.0 2.0 3.0 4.0 5.0 Now, in order to assess the number of columns I would like to have some code like: std::vector<double> vec; double x; while( (...something...) && (istream >> x) ) { vec.push_back(x); } //Here vec should contain 0.0, 1.0 and 2.0 where the...

Can I use a variable to specify the size of a struct member array?

I am trying to represent a HD page in a struct. The code below does not work, because page_size is not a constant. int page_size = 4096; struct page { char data[page_size]; /* some methods */ } Since I am building and randomly accessing arrays of pages, it would be nice if I could treat a page as a fixed length struct of size p...

What is the benefit of the const keyword in programming?

Possible Duplicate: Sell me on using const correctness I'm eager to know the answer. [to "What is the benefit of const keyword in programming?"] ...

Uniquely identify a Computer by it's hardware profile (GetCurrentHwProfile)

Using the GetCurrentHwProfile , we can retrieve the szHwProfileGuid, which is the hardware profile GUID of the machine, i suppose. what is exactly a hardware profile and how is it editable? is the Hardware profile GUID unique by machine? Is the value stored somewhere in the registry and is it updatable? If it is not unique, when exactly...

reading in C++ a socket open by Java + structure alignment

Hi All I am trying to write in Linnux a client in C++ using boost::asio data from a socket. The server is built in Java. The issue I have now is that I cannot read correctly some piece of information from the socket. If the client is done in JAVA everything is ok. In details the big error I have are in receiving the unsigned long and t...

Format a date in C++

Hi, I have a series of date strings in the format: "30-05-2001" string date1 = "30-05-2001"; I would like to parse the date into Day, Month, Year. Now an easy way of doing this would be just to call the function sscanf. But I'd like to explore other possiblilties and from searching the web the following function from time.h was r...