c++

In what ways is MSVC not standards-compilant?

I read that MSVC is not fully compilant to the ISO C++ standard (German Wikipedia and several Tech sites). In which ways isn't C++ standards compilant? ...

Iterator category

In code: //I know that to get this effect (being able to use it with std algorithms) I can inherit like I did in line below: class Iterator //: public std::iterator<std::bidirectional_iterator_tag,T> { private: T** itData_; public: //BUT I WOULD LIKE TO BE ABLE TO DO IT BY HAND AS WELL typedef...

std::vector capacity after copying

Does vector::operator= change vector capacity? If so, how? Does vector's copy constructor copy capacity? I looked through documentation but could not find a specific answer. Is it implementation dependent? ...

Learning to write organized and modular programs

I'm a computer science student, and I'm just starting to write relatively larger programs for my coursework (between 750 - 1500 lines). Up until now, it's been possible to get by with any reasonable level of modularization and object oriented design. However, now that I'm writing more complex code for my assignments I'd like to learn to...

How to pass SAFEARRAY of UDTs to unmaged code from C#.

I also used VT_RECORD. But didn't got success in passing safearray of UDTs. [ComVisible(true)] [StructLayout(LayoutKind.Sequential)] public class MY_CLASS { [MarshalAs(UnmanagedType.U4)] public Int32 width; [MarshalAs(UnmanagedType.U4)] public Int32 height; ...

problem while using #ifndef, .h file being added multiple times

i am trying to use following pattern. #ifndef TRACER_H #include "Tracer.h" #endif This is statement is added to each file in the code such that tracer.h is added only once. Still i am getting an error saying multiple objects Also Tracer.h contains #ifndef TRACER_H #define TRACER_H here is the error i tried prgma onece as well 1>G...

C++ boost thread id and Singleton

hi. Sorry to flood so many questions this week. I assume thread index returned by thread.get_id is implementation specific. In case of the pthreads, is index reused? IE, if thread 0 runs and joins, is thread launched afterwords going to have a different ID? the reason I ask this is a need to implement Singleton pattern with a twist: ...

What is the purpose of using a reference to a reference in C++?

In my adventures studying the boost libraries, I've come across function signatures that have parameters which are a reference to a reference to an object. Example: void function(int && i); What is the purpose/benefit of doing it this way rather than simply taking a reference to an object? I assume there is one if it's in boost. ...

How do I initialize the vector I have defined in my header file?

I have the following in my Puzzle.h class Puzzle { private: vector<int> puzzle; public: Puzzle() : puzzle (16) {} bool isSolved(); void shuffle(vector<int>& ); }; and then my Puzzle.cpp looks like: Puzzle::Puzzle() { // Initialize the puzzle (0,1,2,3,...,14,15) for(int i = 0; i <= puzzl...

What C++ library to use to write a cross-platform service/daemon?

I wonder what library would ease the development of a cross-platform service/daemon ? (C/C++) I'm targeting: Windows, Linux and OS X. Requirements: network operations and serial port communication. Also it would be nice to have a basic sample service application. ...

C++: Shortest and best way to "reinitialize"/clean a class instance

I will keep it short and just show you a code example: class myClass { public: myClass(); int a; int b; int c; } // In the myClass.cpp or whatever myClass::myClass( ) { a = 0; b = 0; c = 0; } Okay. If I know have an instance of myClass and set some random garbage to a, b and c. What is the best way to reset them all to t...

Why is shrink_to_fit non-binding?

The C++0x FCD states in 23.3.6.2 vector capacity: void shrink_to_fit(); Remarks: shrink_to_fit is a non-binding request to reduce capacity() to size(). [Note: The request is non-binding to allow latitude for implementation-specific optimizations. end note] What optimizations are intended to be allowed? ...

PCRE multi line matche problem

Hi guys, i have this C++ program (actually it's just a snippet) : #include <iostream> #include <pcre.h> #include <string> using namespace std; int main(){ string pattern = "<a\\s+href\\s*=\\s*\"([^\"]+)\"", html = "<html>\n" "<body>\n" "<a href=\"example_link_1\"/>\n" ...

How to disable WinMain entry point for a MFC application?

I understand that is not possible to have applications with multiple entry points under Windows. I have a MFC application and I added code for making it running as a service (main() entry point and other required stuff) but it looks that Windows will always run the WinMain() from MFC instead of my main. The question is how can I disabl...

g++ and c++0x specification support

although it's been said that the support for c++0x new features in g++ are in experimental mode, many gcc developer claimed that you can use most of the new features in your codes and get the program to work. but when I try to compile this simple program it results in segmentation fault. Why? #include <thread> #include <iostream> void...

Can my app arrange a gdb breakpoint or watch?

Is there a way for my code to be instrumented to insert a break point or watch on a memory location that will be honored by gdb? (And presumably have no effect when gdb is not attached.) I know how to do such things as gdb commands within the gdb session, but for certain types of debugging it would be really handy to do it "programma...

Managed DirectX as a starting point

I know the difference between manage and unmanaged DirectX. My question is if I decided to do managed directX as a starting point, would it help me to better understand unmanaged DirectX. Honestly, the only thing I see different about the 2 is how you initiate and access resources. Matrix Math is Matrix no matter what so If I learn it in...

How to add a wrapper to the MFC WinMain?

I want to add a wrapper to the MFC WinMain in order to be able to make a MFC application be able run as GUI application or as a service. Can I add a wrapper to WinMail from MFC without modifying MFC source code? ...

How to catch Keyboard and mouse events?

I want to create an application. This application has to do something when a user presses special keys on keyboard or/and uses scroll wheel. This application is a service. It has no windows. I want to catch any keyboard or mouse events which were designed with other applications. For example, you are watching TV by 3rd party application...

can't find what's wrong with my code :(

the point of my code is for me to press f1 and it will scan 500 pixels down and 500 pixels and put them in a array (it just takes a box that is 500 by 500 of the screen). then after that when i hit end it will click on only on the color black or... what i set it to. anyway it has been doing odd stuff and i can't find why: #include <iost...