c++

Difference between "MyClass& func1(void)" and "MyClass* func2(void)"

Possible Duplicate: What is the proper way to return an object from a C++ function ? Hi there, i would like to know whats the difference between the following two functions with respect to the return types? MyClass& func1(void) MyClass* func2(void) I always thought this would be the same? Heinrich ...

Calling a non-void function without using its return value. What actually happens?

So, I found a similar question here, but the answers are more about style and whether or not you are able to do it. My question is, what actually happens when you call a non-void function that returns an object, but you never assign or use said returned object? So, less about whether or not you can, because I absolutely know you can and...

Is it worth writing part of code in C instead of C++ as micro-optimization?

I am wondering if it is still worth with modern compilers and their optimizations to write some critical code in C instead of C++ to make it faster. I know C++ might lead to bad performance in case classes are copied while they could be passed by reference or when classes are created automatically by the compiler, typically with overloa...

Distributing DLLs Inside an EXE (C++)

How can I include my programs dependency DLLs inside the EXE file (so I only have to distribute that one file)? I am using C++ so I can't use ILMerge like I usually do for C#, but is there an easier way to automatically do this in Visual Studio? I know this is possible (thats why installers work), I just need some help being pointed to ...

Anonymous types in C++

I was wondering if there is any equivalent, or a way to fake, C# style anonymous types in C++. I'm using gcc 4.6 so any parts of C++0x it supports can be used. ...

Allocate Virtual memory before running out of RAM

is it possible, in a C/C++ program, to allocate virtual memory (Swap Space) for an specific array, so that the program keeps using RAM for the rest of variables, and maybe getting some benefit at some type of problems?? ...

How to develop an IE plugin that will execute within browser with <OBJECT> tags

I'm new to the realm of web/plugin development and I'm not sure what I need to be researching. What I need is to develop a C++ app/dll/control/something that will install as a browser plugin and can be embedded and ran within IE when <object>...</object> tags call it (or any HTML tag that will embed something of the sort). Exactly ho...

Using a const key for unordered_map

I've been switching my code over from std::map to std::unordered_map where appropriate. With std::map, I typically write the following just to make sure the key cannot be modified: std::map<const std::string, int> Frankly, I never checked if this const was of any value. This has always compiled and worked with g++. Now, with std::u...

Data structure for a random world

So, I was thinking about making a simple random world generator. This generator would create a starting "cell" that would have between one and four random exits (in the cardinal directions, something like a maze). After deciding those exits, I would generate a new random "cell" at each of those exits, and repeat whenever a player would g...

Gui Automation, Install/Uninstall software automatically

Hi, Can anyone please tell me about any open source software which will install and uninstall software automatically without taking input from user for installation steps. Any related material will be highly appreciated. ...

System Error 0x5: CreateFileMapping()

I wish to implement IPC using Named Shared Memory. To do this, one of the steps is getting a handle to a Mapping Memory Object, using CreateFileMapping(). I do it exactly as MSDN website reccommends: http://msdn.microsoft.com/en-us/library/aa366551(v=VS.85).aspx: hFileMappingHandle = CreateFileMapping ( INVALID_HANDLE_VA...

c++ templates without "typename" or "class"

hello! i'm used to write templates like this: template<typename T> void someFunction(SomeClass<T> argument); however - now I encountered templates in another thread written like this: template<U> void someFunction(SomeClass<U> argument); as far as i know one can use "typename" and "class" interchangably (except for some details re...

"Virtual" and Header Files

I have Foo.hpp and Foo.cpp, i'd like to define a virtual function virtual void setValue(int val){ } Would the following implementation be correct: Foo.hpp #ifndef _FOO #define _FOO class Foo{ public: Foo(); virtual void setValue(int val); }; #endif Foo.cpp Foo::setValue(){ } I realise it would be easier if i kept it...

boost::shared_array and aligned memory allocation

In Visual C++, I'm trying to dynamically allocate some memory which is 16-byte aligned so I can use SSE2 functions that require memory alignment. Right now this is how I allocate the memory: boost::shared_array aData(new unsigned char[GetSomeSizeToAllocate()]); I know I can use _aligned_malloc to allocate aligned memory, but will th...

Error: Field has an incomplete type

quaternion.h:15: error: field ‘v’ has incomplete type Hi! I am stuck on an error that I cannot seem to solve. Below is my code: #ifndef QUATERNION_H #define QUATERNION_H #include "vec3.h" class Vec3; class Quaternion { public: Quaternion(Vec3 v); Quaternion(double w, Vec3 v); Vec3 v; <--------------------------This is where ...

Memory Fences - Need help to understand

Hello all, I'm reading Memory Barriers by Paul E. McKenney http://www.rdrop.com/users/paulmck/scalability/paper/whymb.2010.07.23a.pdf everything is explained in great details and when I see that everything is clear I encounter one sentence, which stultifies everything and make me think that I understood nothing. Let me show the example ...

repeating back digits?

Hi, I'm trying to use C++ to grab 5 digits from the user and repeat it back to the user. Unfortunately, the closest I have come to that is by repeating it back backwards... any help here? ...

How to compare vectors with Boost.Test?

I am using Boost Test to unit test some C++ code. I have a vector of values that I need to compare with expected results, but I don't want to manually check the values in a loop: BOOST_REQUIRE_EQUAL(values.size(), expected.size()); for( int i = 0; i < size; ++i ) { BOOST_CHECK_EQUAL(values[i], expected[i]); } The main problem is...

Having issues with #includes and incomplete types

Hi! I have gotten rid of a circular dependence but am still having issues with another problem. I am still learning and hope that someone can explain to me more about what is wrong with my implementation. Sorry for the trouble, but I really appreciate everyone who is helping me. So, the issue I am having now is that in my Vec3 class, i...

discrete event simulators for C++

Hi All, I am currently looking for a discrete event simulator written for C++. I did not find much on the web written specifically in OO-style; there are some, but outdated. Some others, such as Opnet, Omnet and ns3 are way to complicated for what I need to do and, besides, I need to simulate agent-based algorithms capable of simulating ...