c++

Check if C++ Array is Null

how do i do that? well i want to check if the array is empty ...

Boost error codes reference

Does anyone know where to find a reference for boost error codes. In particular, error codes returned by asynchronous socket handlers?, Google and grepping the header files have tuned up empty. Thanks. ...

wfstream not writing

I have the following piece of code in C++: #include <iostream> #include <fstream> #include <string> using namespace std; int main(){ wstring ws1 = L"Infinity: \u2210"; wstring ws2 = L"Euro: €"; wchar_t w[] = L"Sterling Pound: £"; wfstream out("/tmp/unicode.txt"); out.write(ws1.c_str(), ws1.size()); out << ws1...

How can a compiler differentiate between static data members having same name in different classes in C++?

I had a C++ interview recently where I was asked, how does the compiler differentiate static data members having the same name in two different classes? Since all static data variables are stored in the data segment, there has to be a way by which the compiler keeps track of which static data belongs to which class especially when they...

Why does this supersimple NamedPropertyHandler-Stub crash the v8-Runtime?

This is basically the sample code from the 'Getting started' section of the documentation in which I stubbed out an ObjectTemplate provided with a NamedPropertyHandler. The JSON.stringify is just there to trigger an enumeration over the object's keys. The code can be compiled and run as is. #include <v8.h> using namespace v8; Handle...

can the functors called from algorithms acting on a map accept pair<K, V> instead of value_type?

I tried to write a short function to invert an std::map<K, V> (I know about boost.bimap, this is for self-education), and found, to my surprise, that the code that GCC 4.4 accepted with -pedantic -ansi settings was rejected as const-incorrect by SunCC (5.8, from 2005). Since value_type is std::pair<const K, V>, SunCC insisted that I con...

Doubt on a C++ interview question

I have read Answers to C++ interview questions among which there is one that puzzles me: Q: When are temporary variables created by C++ compiler? A: Provided that function parameter is a "const reference", compiler generates temporary variable in following 2 ways. a) The actual argument is the correct type, but it isn't Lv...

Private constructor

Hello, I have an object of class which has private constructor: class CL_GUIComponent { // ... private: CL_SharedPtr<CL_GUIComponent_Impl> impl; CL_GUIComponent(CL_GUIComponent &other); CL_GUIComponent &operator =(const CL_GUIComponent &other); CL_GraphicContext dummy_gc; }; I have a class which has a pointer t...

facet's get_time keeps failing

I have spend like one out in this example, and everytime I get the error Unable to read cin with an ios_base::iostate equal to failbit from this code: #include "dates.h" #include <iostream> #include <ctime> #include <locale> #include <sstream> #include <iterator> using namespace std; void trasnlateDate(istream&in, ostream&out){ c...

overloading operator >>()

My knowledge of C++ is small as I have only taken a couple classes. I undersand the basic case of using a friend function to overload the input, output stream operator for the "simple book example" of a Point object that has x, y instance variables. I am looking at a real project now, trying to understand what someone wrote and am gett...

Can IWebBrowser2 store cookies in a user specified folder?

I am working on a small web browser on c++ using IWebBrowser2, the problem is that when I delete cookies on my browser, they get deleted for IE, and I dont want to interfere with IE cookies. Is there a way to solve this? ...

Parsing positional arguments

Consider the following trivial program adopted from the boost program options examples #include <boost/program_options.hpp> #include <boost/version.hpp> #include <iostream> int main( int argc, char** argv ) { namespace po = boost::program_options; po::options_description desc("Options"); unsigned foo; desc.add_option...

Using C Preprocessor to Determine Compilation Environment

I am building an application that consists of both a windows driver written in C and a user mode executable in c++. They both use a shared header file to define several macros, constants, enums, etc. In the c++ version, I want to include everything within a namespace, which a feature not supported by the c compiler. Is there certain v...

What does the C++ compiler do when coming ambiguous default parameters?

What does the C++ compiler do when coming ambiguous default parameters? For example, let's say there was a function such as: function1(int a = 0, float b = 3.1); function2(int a, float b =1.1, int c = 0); Is the above considered ambiguous? If not, what does the compiler do (how is the function matched exactly) when calling something l...

Using External Lib/DLLs in Qt Creator?

I decided after a bunch of headaches all morning, that using Qt Creator for my first Qt project would probably be better than MSVC (had too many issues compiling). I am wondering though how I can add the .dlls and .libs I need for my external tools through Qt Creator. I found this post http://stackoverflow.com/questions/718447/adding-ex...

C++ standard question

should the following result in undefined behavior? should value of pointer2 be NULL? double *pointer = 0; double &value = *pointer; double *pointer2 = &value; ...

C++ design pattern suggestion

I want to do following, I am writing Graph library. I want my class should be template. template < typename T> class Graph { } This Graph class works on another class Vertex How should I design this Vertex class so that any of my team members can use and I do not have to change my implementation in class Graph Basically I want this ...

C++ library for calculating the matrix exponential

Any recommendations for libraries to implement calculation of the matrix exponential? ...

Where can one find a list of operator overloads?

Where can one find a list of the function signatures for all operator overloads? ...

Get schema data types from Xerces

I am using SAX2 in Xerces C++ and would like to get XML Schema data while I handle elements so that I know their type defined in the Schema. How can I accomplish this? ...