c++

basic c++ pointer question

if I have a function like that: void doSomething(int& aVar) { // do something } and I have this: int *aVar = new int; *aVar = 10; doSomething(*aVar); Why should I call *aVar? isn't aVar already an address? ...

C++ class ordering

I'm starting to play around with C++, coming from C and Objective C (and a bit of Java). I thought a good place to start building my skills is by writing a simple hash table from scratch, using linked lists for collisions. So I started out by writing the skeletons for each class. class HashTable { public: ... private: .....

client / server program in c++ problem

Hi all, I have created a client and server program in c++ based i=on windows sockets. I have some problem that when i execute the program no message appears on the server end and after that the program exits.Data is sending to server but it is not responding back. i am pasting my code below ****Server code ===========**** #ifndef WIN3...

how can I implement factory pattern using C++ class ?

Hi, I am working on a project which was mostly implemented using factory and facade patterns. However I am unable to understand as I do not have a clear concepts of how factory pattern works in C++. Can anybody suggest good sample program or link for the same. Thanks krissam ...

py.test with non-python tests (specifically, with cxxtest)

Hi, I work with a team that develops MPI-based C++ numerical applications. The group uses cxxtest for constructing individual unit tests or small suites, but 1) there are some complications aggregating across directories with cxxtest's usual features and 2) there are some integration tests that are simply easier to implement "from the ou...

How does the compiler determine the location of a member when accessing through a base pointer

This just jumped into my head and I can't figure it out. If I have a code like this: struct A { char x[100]; }; struct B { int data; }; struct C : A, B {}; #include <iostream> using namespace std; B* get_me_some_stuff() { static int x = 0; if (++x % 2 == 0) return new B(); else ...

Determining Calling Line Without Macro

Is it possible to determine the line number that calls a function without the aid of a macro? Consider this code: #include <iostream> #define PrintLineWithMacro() \ std::cout << "Line: " << __LINE__ << std::endl; // Line 4 void PrintLine() { std::cout << "Line: " << __LINE__ << std::endl; // Line 8 } int main(int argc, char ...

Input after cin.getline() fails?

I am new to programming. In my textbook, the problem presented it to write a program that asks a user for the rainfall for three months and calculates the average. I used the cin.getline() function to read the user input into an array. The text states that there is no worry of the array being overflowed using the cin.getline() functio...

Thread safety for STL queue

I am using a queue to communicate between threads. I have one reader and multiple writer threads. My question is do I need to lock the queue every time when I use push/front/pop from the queue for the reader? Can I do something like the following: //reader threads getLock(); get the number of elements from the queue releaseLock(); int ...

How to call WMI function correctly

The following code fails when ExecMethod is called. Can anyone pinpoint what I am doing wrong? #define _WIN32_DCOM #include <iostream> using namespace std; #include <comdef.h> #include <Wbemidl.h> # pragma comment(lib, "wbemuuid.lib") int main(int iArgCnt, char ** argv) { HRESULT hres; // Step 1: ----------------------------...

USB RF Receiver Mouse Hacking

How do wireless mice work, as in technically, the RF Receiver you plug in via USB (PnP)? I want to know how I would go about accessing the data section of the receiver and see either the actual code involved in sending information to the OS driver, or see the drivers involved to go about decompilation. ...

what is the media player uid in symbian^3 (N8 device)

in my application,i just wanna open a url contain media,e.g. http://www.test.com/test.mp3,or rstp://www.test.com/test.3gp,so i need the symbian embeded media player's uid to open it. ...

How to turn on STL backward compatability?

I am trying to compile something that uses Google's sparsehash include files. libs/include/google/dense_hash_map:93:60: error: ext/hash_fun.h: No such file or directory ^Cmake: *** [all] Interrupt I know that hash_fun.h exists in /usr/include/c++/4.3/backward/hash_fun.h. I am just not sure how to make google sparse hash use it. Any id...

C++ How to create a dynamic array of integers

C++ How to create a dynamic array of integers using new Keyword ? ...

LSA Returns STATUS_BAD_VALIDATION_CLASS

Hello, I'm building an Authentication Package for Windows and I'm now just trying to make a skeleton for the package that I'm going to build. The Package at some point in time will need to call MSV1_0 but the workflow of my authentication is forbidding me from implementing it as a SubAuthentication Package for MSV1_0. Now, please exa...

C++: What are scenarios where using pointers is a "Good Idea"(TM)?

Possible Duplicate: Common Uses For Pointers? I am still learning the basics of C++ but I already know enough to do useful little programs. I understand the concept of pointers and the examples I see in tutorials make sense to me. However, on the practical level, and being a (former) PHP developer, I am not yet confident to ...

Overhead of DLL

Hi All I have a quite basic question. When a library is used only by a single process. Shall we keep it as static library..? If i use library as DLL,But only a single process use it . what will be overhead Thanks Sat ...

Curious question : What algorithm does STL set_intersect implement?

I spent a considerable amount of time coding in Baeza-Yates' fast set intersection algorithm for one of my apps. While I did marginally out-do the STL set_intersect, the fact that I required the resultant set to be sorted removed any time I had gained from implementing my own algorithm after I sorted the output. Given that the STL set_in...

State of static variable in DLL

Scenario: My Application bind a library X which has static class. I initialize it in my process. After some time when I load a dll which also use same library X. I see content of static variable in dll is not initialized. Where I already initialized it in process before loading DLL. I added initialization code in DLL main , and its ...

Borland c++ exception

i am using the Borland c++ 3.1 compiler. I want to work with exceptions, i've written the following code: void main (void) { int a = 0; int b = 1; int c; try { throw 1; } catch(int a) { b = a; } } The compiler returns a syntax error. what's wrong? ...