c++

C++ const keyword - use liberally?

In the following C++ functions: void MyFunction(int age, House &purchased_house) { ... } void MyFunction(const int age, House &purchased_house) { ... } Which is better? In both, 'age' is passed by value. I am wondering if the 'const' keyword is necessary: It seems redundant to me, but also helpful (as an extra indication th...

Create new C++ object at specific memory address?

Is it possible in C++ to create a new object at a specific memory location? I have a block of shared memory in which I would like to create an object. Is this possible? ...

Why does Windows not allow WinSock to be started while impersonating another user

Using my own program or others I can't get winsock to run when calling if the process is created with CreateProcessWithLogonW or CreateProcessAsUserW. It returns this error when I create the socket: WSAEPROVIDERFAILEDINIT 10106 Service provider failed to initialize. The requested service provider could not be loaded or initiali...

D.R.Y vs "avoid macros"

I am creating my own implementation of XUL in C++ using the Windows API. The fact that the elements are constructed by the XML parser requires that they have identical interfaces, so that we don't need to write custom code for each element constructor. The result is that most of my elements look like this: class Button : public Element ...

not-yet-commons SSL and Open SSL, Java and C++, Common Ground?

The not-yet-commons SLL package for Java provides an OpenSSL object with a method for password based encryption: encrypt("des", password, data); This method is said to be compatible with the OpenSSL C library. My question is, what is the OpenSSL C++ method equivalent to the above Java? Thanks ...

C++: LINK : debug\XXXXX.exe not found or not built by the last incremental link; performing full link

Using visual studio 2008 SP1, This line: LINK : debug\XXXXX.exe not found or not built by the last incremental link; performing full link appears every single time I compile the project, no matter how small a change I make. What could be the reasons for that? ...

How to explain source control and best practices to non-technical managers?

My manager recently asked, "Is there a standard procedure or process that is typically used by businesses to ensure the file integrity of files -- maintaining their separateness from those that are involved in work-in-progress projects -- yet permitting all necessary users to gain access to the most up-to-date and accurate files?" Of co...

C++ char** -> vector<string> -> string -> char** parsing problem

Lets say that I'm trying to solve a parsing problem of string to char ** For some reason the below code generates a lot of trash, can anyone have a look at it please? Here's what it's supposed to do : Dump all argv into a string_array container Dump everything in the string_array container into a std::string and separate with spaces Br...

Const Correctness Question in C++

I have a random question about const correctness. Lets say i have a class that is a singleton. class Foo : public Singleton<Foo> { friend class Singleton<Foo>; public: std::wstring GetOrSet(const int id) const; private: Foo(); ~Foo(); void LoadStringIntoMap(const int id, const std::wstring &msg); std::map<int...

VB6 GUI not working in multithreaded COM environment

I have a VB6 COM client that makes calls to an inprocess STA ATL/COM server. One of the Server methods, X, can take a while to finish so I need to be able to cancel it. What I tried was to run the method code in a new thread and include another method, Y, that does a timed WaitForSinleObject. So the client first calls X then goes into a ...

Which is latest C++ Standard Release , From where i can download it

Possible Duplicate: Where do I find the current {X} standard? I have a simple Question ! I am looking for soft copy of latest C++ Standard release. I have ISO/IEC 14882 First Edition ,1998-09-01, But i have doubt if it is latest. I visited http://www.open-std.org/jtc1/sc22/wg21/, There are many drafts. Please guide me which...

Initializing an array in C++

I am trying to initialize an array of objects: SinglyLinkedList offeredClasses[22] = {SinglyLinkedList("CSCE101"),SinglyLinkedList("CSCE101L"),SinglyLinkedList("CSCE150E"),SinglyLinkedList("CSCE150EL"),SinglyLinkedList("CSCE150EM"),SinglyLinkedList("CSCE150EML"),SinglyLinkedList("CSCE155"),SinglyLinkedList("CSCE155H"),SinglyLinkedList("...

Including stdc++ from iPhone app

I'm trying to use clucene from inside an iPhone application, and I'm running into issues with my include statements. Specifically, imports like stdexcept, vector, etc are failing. The same code compiled fine under XCode using the x86_64 sdk, but fails when I switch to the iPhone Simulator 3.1 sdk. It seems like XCode might be changing ...

C++ c_str doesn't return entire string

I've tried the following code with both normal ifstreams and the current boost:iostream I'm using, both have the same result. It is intended to load a file from physfs into memory then pass it to a handler to process (eg Image, audio or data). Currently when c_str is called it only returns a small part of the file. PhysFS::FileStr...

I'm an experienced C# developer, what things should I know to code effectively in c/c++?

I have a little bit of experience in c/c++ from college but have not worked in it for years. What sorts of things do I need to know to even be considered for a c/c++ job position? ...

Shared pointers and the performance

Hello. I have been using shared pointers for soem time now, and I have performance issues in my program... So I'd like to know if shared pointers lead to performance decrease. If so, then how hard? Thanks alot. My program is multi-threaded, using std::tr1::shared_ptr ...

Problem between a QTcpServer and a TCPClientSocket (Cayuga)

I try to communicate via TCP Socket between a QT4-Application (MyApp) and Cayuga (written in C++). The connection part works fine, i.e. Cayuga connects to MyApp. Now, MyApp is sending some data to Cayuga, but nothing is received. void MyApp::init() QTcpServer *m_server; QTcpSocket *clientConnection; //Open socket for transmission m...

deleting char ** correctly?

I've created a 2d array of c-strings using : char ** my_array = new char*[N]; and then I initialized each row using : my_array[i] = new char[M]; // where M is a varying number. assign values to my_array[i] later So I pretty much got a jagged 2d array. I wanted to proceed and delete the whole thing like this : for(int i = 0; i < N...

Socket Programming for Windows C/C++

Hi to all, I have write a game on OpenGl, and want to make it a multiplayer game. I'm working on Windows, but I'm actually a C#-programmer. Socket programming goes too easy at C#, but at c++ I can not solve it :( Which library should I use? winsock and winsock2 libraries are too complicated. Is there any library easy to use like in C#...

Making a non-object resource RAII-compliant

Hello, in my code I use HANDLEs from windows.h. They are used like HANDLE h; if (!openHandleToSomething(arg1, arg2, &h)) { throw std::exception("openHandleToSomething error"); } /* Use the handle in other functions which can throw as well */ if (!CloseHandle(h)) { throw std::exception("closeHandle error"); } As you see, you h...