c++

Accessing a subslice of a boost matrix in a helper class

I'm trying to build a class that eases the use of the boost boost::numeric::ublas::matrix. Thus I've got: using namespace boost::numeric::ublas; typedef matrix<double> matrix_t; class Tensor : public matrix_t { public: Tensor (const int M, const int N) : matrix_t(M, N) { } virtual ~Tensor() { } Tensor SubMatrix (const...

"T* ptr" vs "T *ptr" declaration

Possible Duplicate: C++: Asterisks and Pointers First of, excuses if this is a duplicate, it was kind of hard to find any results using the search so I assume it hasn't been asked yet (which I don't believe) As it appears, there's two different pointer (and for C++: reference) declaration conventions. Some people prefer to us...

Specifying test dependencies in CppUnit?

I would like to specify the order of testing in CppUnit. According to my research, the testing order depends on either the compiler or linker and how they came across the files. How does one specify dependencies in CppUnit? For example, let us consider a rectangle class that has four lines. Each line contains two point classes. As...

Can read(2) return zero when not at EOF?

According to the man page for read(2), it only returns zero when EOF is reached. However, It appears this is incorrect and that it may sometimes return zero, perhaps because the file is not ready to be read yet? Should I call select() to see if it is ready before reading a file from disk? Note that nBytes is: 1,445,888 Some sample co...

How do I get the regex matched value using Boost.Regex?

I'm trying to extract the domain from a URL. Following is an example script. #include <iostream> #include <string> #include <boost/regex.hpp> int main () { std::string url = "http://mydomain.com/randompage.php"; boost::regex exp("^https?://([^/]*?)/"); std::cout << regex_search(url,exp); } How do I print the matched value? ...

How to fix file path case?

I have a set of local paths, and some of them are capitalized (C:\SOMEDIR\SOMEFILE.TXT). I need to convert them to their real names (as shown in Explorer). Suggest a way plz. ...

Is g++ on cygwin any different from what I get on Linux platform?

Can I start installing boost libraries, ACE framework and use it as my home Linux server? ...

Programming Games for iPhone

Is it best to program a game for the iPhone in Objective C or in C++. What language would a game like Flight Control be written in? What format should graphics be in to show properly and load quickly on the iPhone? ...

Collision detection in STL's hash_map

I have to create a lookup table for C function names (as keys) to function pointers (as values). I am thinking of using STL's hash_map container, as the access time of a hash table is O(1). Is there any good hash function for this? Currently I am using (31*H + c) as my hash function. Also, does STL's hash_map takes care of collisions, o...

Why am I able to create a copy constructor and overload the assignment operator for a QObject subclass?

I was under the impression that QObject disabled the copy constructor and assignment operator... why am I able to compile this QObject derivative containing both of these? #ifndef QVERSION_H #define QVERSION_H #include "silverlocklib_global.h" #include <QtCore> struct SILVERLOCKLIBSHARED_EXPORT QVersion : public QObject { Q_OBJECT...

Checking for redundant included header files

Is there any way to find out all the redundant header files included in a C/C++ source file? Thanks in advance ...

What is the difference between pointer to function and pointer to WINAPI function?

Hi, I came accross a code snippet which detects whether app is running in x32 emulated environment on x64 PC here Generally I understand that code but there is one thing I don't get: 1) typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); Why does WINAPI have to be there? Why is it so important to know that pointer doesn't p...

how to catch unknown exception and print it

hello to everyone, I have some program and everytime I run it, it throws exception and I don't know how to check what exactly it throws, so my question is, is it possible to catch exception and print it (I found rows which throws exception) thanks in advance ...

Algorithms in C++ by Robert Sedgewick experiences

How good is this book for learning algorithm creation, based on experiences ? ...

typedef and incomplete type

Recently I am having many problem with typedef and incomplete type when I changed certain containers, allocators in my code. What I had previously struct foo;//incomplete type. typedef std::vector<foo> all_foos; typedef all_foos::reference foo_ref; Though not completely not sure whether the above lines are legal, but this worked on e...

Why do compilers allow string literals not to be const?

And where are literals in memory exactly? (see examples below) I cannot modify a literal, so it would supposedly be a const char*, although the compiler let me use a char* for it, I have no warnings even with most of the compiler flags. Whereas an implicit cast of a const char* type to a char* type gives me a warning, see below (tested...

Calling base class method from derived constructor

class Base { public: Base() {} void Foo(int x) {...} }; class Derived : public Base { public: Derived(int args) { /* process args in some way */ Foo(result); } }; Is it allowed to call a method of the base class in the constructor of the derived class? I would imagine this is fine as the Base ...

Does there exist a humorous C++ tutorial?

I'm looking for something along the lines of Learn you a Haskell or Why's Poignant Guide to Ruby, but for C++. Does such a thing exist? Or at least something not extremely dry, and a bit more welcoming to someone new to the world of C++? ...

Creating effects in 3D game from scratch, using c++ and DirectX

So the title says it. I couldn't find any info on how actualy build effects into 3D game. I'll maybe stick to some engine later, but for understanding of this whole thing I would need to try it on my own for this time. I found a few about particle systems which may be the right way but any other connection between DirectX and particle sy...

How to ensure class template argument is derived from particular class Foo?

Possible Duplicate: C++ class template of specific baseclass class Base { ... }; class Derived1 : public Base { ... }; class Derived2 : public Base { ... }; class Unrelated { ... }; I want to have a class template ClassTemplate that accepts as parameter only classes Derived1 and Derived2 but not Unrelated, so I can do: C...