c++

How does one obtain the Windows installation date, without using WMI?

Not much to say about this question... ...

C++ Primer (Stanley Lippman) or The C++ programming language (special edition)

I have a Computer Science degree (long2 time ago) .. I do know Java OOP but i am now trying to pick up C++. I do have C and of course data structure using C or pascal. I have started reading Bjarne Stroustrup book (The C++ Programming Language - Special Edition) but find it extremely difficult esp. some section which i don't have expo...

C++ best practice: Returning reference vs. object

Hi folks, I'm trying to learn C++, and trying to understand returning objects. I seem to see 2 ways of doing this, and need to understand what is the best practice. Option 1: QList<Weight *> ret; Weight *weight = new Weight(cname, "Weight"); ret.append(weight); ret.append(c); return &ret; Option 2: QList<Weight *> *ret = new QList...

What makes this "declarator invalid"? C++

I have Vertex template in vertex.h. From my graph.h: 20 template<class edgeDecor, class vertexDecor, bool dir> 21 class Vertex; which I use in my Graph template. I've used the Vertex template successfully throughout my Graph, return pointers to Vertices, etc. Now for the first time I am trying to declare and instantiate a Vertex obje...

C++ Variable declarable in function body, but not class member?

I want to create a C++ class with the following type: It can be declared inside of a function. It can be declared inside of a member function. It can not be declared as a class member. The use of this: think "Root" objects for a GC. Is this possible in C++? In particular, I'm using g++. Willing to switch to clang. Either templates o...

GCC problem with raw double type comparisons

I have the following bit of code, however when compiling it with GCC 4.4 with various optimization flags I get some unexpected results when its run. #include <iostream> int main() { const unsigned int cnt = 10; double lst[cnt] = { 0.0 }; const double v[4] = { 131.313, 737.373, 979.797, 731.137 }; for(unsigned int i = 0; i ...

creating matrix with probabilities

Hi all, I want to generate a matrix of NxN to test some code that I have where each row contains floats as the elements and has to add up to 1 (i.e. a row with a set of probabilities). Where it gets tricky is that I want to make sure that randomly some of the elements should be 0 (in fact most of the elements should be 0 except for so...

Tips Unit testing modal class in passive view pattern

Hello All, I am new to unit testing. I have done unit testing on controller classes but have never tested modal class. I am using passive view pattern for my application. I am using Cpp Unit test framework. Any tips would be highly appreciated. Thanks Rahul ...

VS 2005 can't find .NET DLL class definitions even after Regasm

I have an unmanaged C++ project that uses a third-party .NET dll. It builds fine on one machine, but not on another--the IDE can't find the class definitions. I ran RegAsm.exe TheLib.dll /codebase /tlb:TheLib.tlb, and the registry entries on the two machines match. That is, even though the IDE says that TheLib.Function() is undefined,...

In a C++ template, is it allowed to return an object with specific type parameters?

When I've got a template with certain type parameters, is it allowed for a function to return an object of this same template, but with different types? In other words, is the following allowed? template<class edgeDecor, class vertexDecor, bool dir> Graph<edgeDecor,int,dir> Graph<edgeDecor,vertexDecor,dir>::Dijkstra(vertex s, bool prin...

Best way to encrypt a directory of files?

I need to programatically encrypt a directory of files, like in a .zip or whatever. Preferably password protected obviously. How can I accomplish this, and WHAT IS the BEST encryption way to do it, if applicable? Programming language doesn't matter. I am dictioned in all syntax. ...

how to print correctly the handling thread on Windows?

Hi, Could someone please tell us on how to print correctly the handling thread in windows? Actually I tried several ways but it doesn't return the right number as in Unix-variant, as such e.g.: cout << " with thread " << pthread_self << endl; cout << " with thread " << pthread_self().p << endl; Thanks for your replies: ...

how do I get a part of the a string in C++

I am just wondering how do I get a part of a string in C++, like I want to know what are the elements from 0 to i. Thanks. ...

Which to use - "operator new" or "operator new[]" - to allocate a block of raw memory in C++?

My C++ program needs a block of uninitialized memory and a void* pointer to that block so that I can give it to a third party library. I want to pass control of the block lifetime to the library, so I don't want to use std::vector. When the library is done with the block it will call a callback that I have to supply and that will dealloc...

C++: Declaration of template class member specialization

When I specialize a (static) member function/constant in a template class, I'm confused as to where the declaration is meant to go. Here's an example of what I what to do - yoinked directly from IBM's reference on template specialization: ===IBM Member Specialization Example=== template<class T> class X { public: static T v; st...

Login to a remote machine & accessing network resources

Hi, I want to access a file on remote machine(win2k3, 10.10.20.30), but i couldn't understand how to login to that machine in my program. is there any simple win api that takes network path, credentials and returns the handle? i just want to access \10.10.20.30\c$\test.txt, WNetAddConnection2, WNetAddConnection3 are little confusing. A...

How do I send floats in window messages.

Hi, What is the best way to send a float in a windows message using c++ casting operators? The reason I ask is that the approach which first occurred to me did not work. For the record I'm using the standard win32 function to send messages: PostWindowMessage(UINT nMsg, WPARAM wParam, LPARAM lParam) What does not work: Using stat...

Imbricated C++ template

I have the following pattern: template <int a, int b> class MyClass { public: template <int c> MyClass<a, c> operator*(MyClass<b, c> const &other) const; }; // ../.. template <int a, int b> template <int c> MyClass<a, c> MyClass<a, b>::operator*(MyClass<b, c> const &other) const //< error here { MyClass<a, c> result; // ..do s...

C/C++ method parameter hints in Eclipse

Hello, is there any way how to enable Eclipse to show hints for parameters of C/C++ functions. When I press Ctrl + Shift + Space it shows only types of parameters but not the names. And is there also any way Eclipse can show parameter hints automatically when ( is pressed? Thanks for any advice. ...

Loading and storing encryption keys from a config source

I am writing an application which has an authenticity mechanism, using HMAC-sha1, plus a CBC-blowfish pass over the data for good measure. This requires 2 keys and one ivec. I have looked at Crypto++ but the documentation is very poor (for example the HMAC documentation). So I am going oldschool and use Openssl. Whats the best way to g...