c++

how to call C++ dll function with int& and int* parameters from C#?

My C++ DLL have a function like this: void func1(int& count, int* pValue); this function will determine the "count", and put some values into the pValue int array which is the length of "count". how can I define my C# code? you can ignor the [DllImport ...] part. thanks, ...

In C++, does adding a friend to a class change its memory layout ?

Also, does it matter where in the class you declare the friend ? Does it matter if you add a friend class or a friend function ? ...

OpenCL for commercial apps, byte code?

I'm looking at options for GPGPU work. Say I write OpenCL kernel code or GLSL shader code and embed that in my executable. There's nothing to stop somebody grep-ing the binary and stealing my hard work. I could obscure or encrypt the strings and decrypt them just-in-time, but somebody can always go in with a debugger and intercept that j...

Drawing the alpha channel correctly in OpenGl.

After loading an image, I have the individual bytes for each channel loaded into an array of unsigned characters. It's passed to a function that projects it as a texture onto a quad. Everything seems to work properly other than the alpha channel, which shows up as the background color. I'm using OpenGL to draw the image. Would I benefit ...

Is there a way to Boost.Assign a ptr_vector?

Usually like this: #include <boost/assign/std/vector.hpp> vector<int> v; v += 1,2,3,4,5; Except for a: #include <boost/ptr_container/ptr_vector.hpp> boost::ptr_vector<int> v; If you need to know the reason; I'm using ptr_vector instead of vector only so I don't have to delete elements, but I need to initialize it using Boost.Assign...

Why must the copy assignment operator return a reference/const reference?

In C++, the concept of returning reference from the copy assignment operator is unclear to me. Why can't the copy assignment operator return a copy of the new object? In addition, if I have class A, and the following: A a1(param); A a2 = a1; A a3; a3 = a2; //<--- this is the problematic line The operator= is defined as follows: A A:...

Visual Studio 2010 indentation after for loop.

Why am I getting this behavior right after the if block? Am I missing something? for (;;) if (/*...*/) { // statements } // statements indented to match the if indentation instead of the for loop; ...

Set background color of a control? (WinAPI)

How can I set the backcolor of a control (equivilant of control.backcolor in .Net). I tried setBKColor with no luck. ex: TabHwnd = createWindowEx(NULL,WC_TAB.... then how could I set the back color of TabHwnd? Thanks ...

How do I increment an enum in VS C++ 6.0?

I copy and pasted some code that increments an enum: myenum++; This code worked fine as it was compiled in VS.NET C++ 2003 I am now developing in VS 6.0 and get the error: error C2676: binary '++' : 'enum ID' does not define this operator or a conversion to a type acceptable to the predefined operator How can I get t...

Is there a stoll()/stroll() (string to long long) alternative in Visual Studio 2008

Is there an alternative, either built into windows or apache license compatible, to stoll() for Visual Studio 2008. Even installing the windows 7 platform SDK does not add stoll() to the string header. On unix the same function is be called strtoll(). ...

Polymorphism: Accessing inherited class variable

Hi, I have a class that is inherited from an abstract base class. class CStateBase { friend class CApplication; friend class CGraphics; virtual int Update() =0; }; class CStateTitle: private CStateBase { friend class CApplication; friend class CGraphics; CApplication *f_App; int m_iR; int Update(); CStateTitle(CApp...

Is there a simple library for C++ to draw to the screen?

Hello, I'm just starting out in C++ programming and I want to try creating a space invaders clone in C++, I want to avoid using game libraries and things that would solve a lot of the problems (like game loop and vector maths etc) so I can tackle these myself, but, I have no idea how to begin drawing things to a screen. I was wondering...

Can someone please explain move semantics to me?

I just finished listening to the Software Engineering talk radio podcast interview with Scott Meyers regarding C++0x. Most of the new features made sense to me and I am actually excited about C++0x now, with the exception of one. I still don't get "Move Semantics"... What are they exactly? ...

Programmatically Save an Excel File Using OLE

How do you programmatically save an excel workbook using OLE and C++ Builder? I'm guessing it might be something like: Variant excel = Variant::CreateObject("Excel.Application"); excel.OleProcedure("Save"); // but how might you specify the file name ...

Template object as static member of the template class

Imagine the following template class (setter and getter for the member _t omitted): template<class T> class chain { public: static chain<T> NONE; chain() : _next(&NONE) {} ~chain() {} chain<T>& getNext() const { return *_next; } void setNext(chain<T>* next) { if(next && next != this) _next = next; ...

Preventing copy construction and assignment of a return value reference

If I have a function that returns a reference to an instance of a class that I don't have control over its source, say list<int>: list<int>& f(); I want to ensure that its value is only assigned to another reference, e.g.: list<int> &a_list = f(); If the user were instead to do: list<int> a_list = f(); // note: no '&', so the list...

Boost Asio On Linux Not Using Epoll

I was under the impression that boost::asio would use an epoll setup by default instead of a select implementation, but after running some tests it looks like my setup is using select. OS: RHEL 4 Kernel:2.6 GCC:3.4.6 I wrote a little test program to verify which reactor header was being used, and it looks like its using the select reac...

template fails to compile: 'double' is not a valid type for a template constant parameter

template<typename T, T Min> class LowerBoundedType {}; template<typename T> class vectorelement {}; template<> class vectorelement<Categorical> { typedef LowerBoundedType<double, 0.0> type; }; with error: error: 'double' is not a valid type for a template constant parameter ...

ATL Compile Error when using attribute implements_category

I'm following through a tuturiol to develop a tool for ArcGIS, and everything seems to work fine except that ArcGIS requires the ATL attribute implements_category(__uuidof(CATID_ControlsCommands)) to be specified in order for the control to be accessable from the host software (ArcMap). Unfortunately, this always throws the error (31) : ...

Make child windows inherit parent background color?

Is there a way for windows created with WS_CHILD to inherit the parent's background color rather than default to Dialog Color? I'm trying to do this for a tab control, mainly the part that extends due to the tabs not filling up the area. I want this color to be the parent window's BG. Thanks ...