c++

Which of these is faster ?

I was wondering if it was faster to render a single quad the size of the window with a texture the size of a window than to draw the bitmap directly to the window using double buffering coupled with the platform specific way of drawing to a window. ...

creating input iostream input manipulator

As an exercise, I'm trying to create a input stream manipulator that will suck up characters and put them in a string until it encounters a specific character or until it reaches eof. The idea came from Bruce Eckel's 'Thinking in c++' page 249. Here's the code I have so far: #include <string> #include <iostream> #include <istream> #in...

assignin sockaddr to another changes the addr?!?

While trying the following the address in the second sockaddr changes: /*Stuff*/ sockaddr add1, add2; recvfrom(/*socket*/, /*buffer*/, /*count*/, /*flag*/, &add1, /*fromlen*/); add2 = add1; //The sa_data - part changes O_o... /*Stuff*/ Anyone knows why?... EDIT: 1.I changed the sockaddr to sockaddr_storage which definetly has enou...

WCHAR wszFoo[CONSTANT_BAR] = {0}; <-- What does {0} mean?

WCHAR wszFoo[CONSTANT_BAR] = {0}; I've never seen something like {0} used in C++ as part of the language. And I have no idea how to search for a question like this online. What is it? ...

Filling an array passed as a parameter with objects

I have a function similar to this: void foo(obj ary[], int arysize) { for (int i = 0; i < arysize; i++) ary[i] = obj(i, "abc"); } And I call it like this: obj array[5]; foo(array, 5); It's supposed to populate the array with my objects. However, when it returns, the objects are garbage. It works with value types like i...

Project ideas to become good at C++

I want to get into C++ team at work. Their job is to write CGIs in C++ (mainly but not limited to). I know basic C++. Reading the list at C++ book guide question on SO, I've got three books from a friend (I actually had the first one). The C++ Programming Language - Bjarne Stroustrup - for reference C++ Templates The Complete Guide - ...

Boost Thread not detaching when it is created as a member function of a class.

The simplified version of my code looks as follows: class threadCreator { void threadFunction(void){ // use some private data members and do something. } void createThread(void){ boost::thread myThread( boost::bind(&threadCreator::threadFunction,this)); myThread.detach(); } } This program wa...

Is doxygen the (de facto) standard documentation syntax specification?

We all have the good habit of documenting our code, right? Nowadays, in-code documentation itself has a syntax. It's almost like a programming language onto itself. The questions are: What (How many) documentation syntax specifications exist? Is there a standard documentation syntax? Who is defining this standard? Is there an of...

What is the fact of DirectUI ?

I am working on a windows desktop application which needs a great UI. I use Visual studio and MFC now. Then heard of DirectUI technology is a good solution, but I can not find some articles on "DirectUI". Can you give me some tech. points on "DirectUI" ? If it's possible to implement a DirectUI library for future use? Thanks. ...

Looking to write electrical engineering related open software

I apologize if this question is a little broad. Hopefully your answers will help me narrow it down to more meaningful questions. I'm experienced in software engineering and had a recent conversation with a friend who suggested that electrical engineering is very software driven these days. I'm trying to improve my understanding of th...

string function

please can anybody explain me what this function do?i am confused bool isOnlyLeftHand(string w) { return (w.find_first_not_of("qwertasdfgzxcvb") == string::npos); }//end isOnlyLeftHand ...

modifying small part of an existing file

I looked at boost's mapped_file, and CreateFileMapping/MapViewOfFile, but they seem overly complicated to use. Anything simpler I can use to overwrite a few bytes here and there in an existing file? Performance is not a very high consideration. ...

How to achieve pushbutton type effect using bitmaps

Hello there I have a issue related to the usage of the bitmap enabled Dialog window.I have created a keyboard type layout and i wish to get the input through keyboard also.When i use the mouse I am able to get the button(s) pressed and also all the buttons are working fine - the other images DEFAULT,SELECTED,DISABLED ..all get loaded and...

Why does this code compile?

Last night, being too tired, I wrote this strange line: ::TerminateThread(::TerminateThread, 0); To my surprise, the compiler does not complain (It even run...) Since TerminateThread() is defined as BOOL WINAPI TerminateThread(HANDLE hThread, DWORD dwExitCode); I'm no sure why I am able to compile it. Any explanation? ...

Trying to compile libdwarf, gives undefined errors

I'm trying to build the libdwarf api under windows but I'm receiving the following compile errors. in dwarf_elf_access.c undefined type Elf32_Ehdr, undefined symbol EI_CLASS undefined symbol ELFCLASS64 undefined symbol ELFDATA2LSB ... I did a search through all the header files and source files and I couldn't find them defined anywher...

Overloading the C++ indexing subscript operator [] in a manner that allows for responses to updates

Consider the task of writing an indexable class which automatically synchronizes its state with some external data-store (e.g. a file). In order to do this the class would need to be made aware of changes to the indexed value which might occur. Unfortunately the usual approach to overloading operator[] does not allow for this, for exampl...

Advantages of using forward

In perfect forwarding, std::forward is used to convert the named rvalue reference t1 and t2 to unnamed rvalue reference. What is the purpose of doing that? How would that effect the called function inner if we leave t1 & t2 as lvalue? template <typename T1, typename T2> void outer(T1&& t1, T2&& t2) { inner(std::forward<T1>(t1), std...

Parse and remove part of a QString

I want to parse some kind (or pure) XML code from a QString. My QString is like: <a>cat</a>My cat is very nice. I want to obtain 2 strings: cat, and My Cat is very nice. I think a XML parser is not maybe necessary, but in the future I will have more tags in the same string so it's also a very interesting point. ...

Suggest me a better way to make Algoritham Simulator(VIrtual Lab)

Hello i am developing an Algorithm Simulator(Virtual Lab),first let me describe it briefly: DESCRIPTION There are so many different type of algorithms in Data Structures like Searching algorithms,Sorting algorithms,Tree traversal algorithms etc. So i am developing a desktop application in which a user can input the elements and wh...

Program works fine in Debug build, but fails in Release build

I am facing a problem in release build of Visual Studio pseudo code is given below #include "lib/A/inc/A.h" main() { A a; a.f1();//this fails in release build and works fine in debug build a.f2();//this fails in release build and works fine in debug build } A is derived from B present in lib/B/inc/B.h class A :public B { vi...