I have multiple classes that are quite different in their behavior, but at the same time, share common functions that have to access the member variables.
So what I want to do, is to create a templated member function to avoid extra copy-paste code duplication.
The final result should be like:
ClassA::CallFoo()
ClassB::CallFoo()
Class...
During initialisation of my program I call SDL_SetVideoMode() just after SDL_Init() and it is hanging my program.
When executing the program, if I press Ctrl-C during the hang it will continue as normal and all works fine.
Obviously having to interupt SDL_SetVideoMode() every time isn't ideal! Anyone have any ideas on what this could b...
I don't want function pointer overhead, I just want the same code for two different functions with the same signature:
void f(int x);
void g(int x);
...
template<typename F>
void do_work()
{
int v = calculate();
F(v);
}
...
do_work<f>();
do_work<g>();
Is this possible?
To clear up possible confusion: With "template paramete...
Hi,
Whilst working with the MSI Interop API I have come across some unusual behaviour which is causing my application to crash. It is simple enough to 'handle' the problem but I would like to know more about 'why' this is happening.
My first call to MSIEnumRelatedProducts returns an value of 0 and correctly sets my string buffer to a ...
Is there any standardized way (not language dependent, I need at least C++, Java and Ruby) of listening for changes in a DOM-document? I would like to have a function called every time a node's attributes change, a node gets renamed, deleted, etcetera.
I found the Handlers for UserData, however those don't allow me to listen for e.g. ch...
Hi,
I'm beginner to Qt and I see that most of widgets that are build in in Qt do not appear in the widgets tool box.
How can I add all the widget to tool box? (Like QSystemTrayIcon that does not appear by default in tool box)
what is the best way to write gui - by the designer - ui file or by code - cpp file?
Thanks!
...
I have created an enumerated data type to define possible flight lengths. I'd like to overload its << operator so the representation is nicer.
When I compile this, I get the following error (posted for completeness' sake. Basically multiple definitions of operator <<(ostream&, Categoria&)):
g++ -oProjectoAEDA.exe src\voo.o src\tui.o sr...
i have converted a C++ library to managed and get the following error on this code line:
std::ifstream fin(filename, std::ifstream::in);
Errors:
Error 30 error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0003b5). C:\Users\Freeman\Documents\Visual Studio 2010\Projects\testsharp1\cpp1\MSVC...
Any one Explain this with an example
"Involving conversions on a function argumentsinvolved in template
parameter deduction."
EXamples like this:
template<class T> struct B { /* ... */ };
template<class T> struct D : public B<T> { /* ... */ };
template<class T> void f(B<T>&);
void g(B<int>& bi, D<int>& di)
{
f(bi);
...
Greetings.
I am trying to compile a 8hz mp3 encoder - C code in QT Creator.
In a file l3psy.c that starts like this
#include <stdio.h>
#include "types.h"
#include "error.h"
#include "layer3.h"
#include "l3psy.h"
#include "fft.h"
#include "tables.h"
The build step complains about PI being undeclared here
for(i=0;i<BLKSIZE;i++) wi...
I am trying to compile the following for the android ndk
#include <jni.h>
#include <string.h>
extern "C" {
JNIEXPORT jstring JNICALL Java_com_knucklegames_helloCpp_testFunction(JNIEnv * env, jobject obj);
};
JNIEXPORT jstring JNICALL Java_com_knucklegames_helloCpp_testFunction(JNIEnv *env, jobject obj) {
return env->NewStringUTF(...
I have a problem trying to get my head around using UTF8 with Poco::XML::XMLWriter. In the following code example, everything works fine when the input contains ASCII characters. However, occasionally the string in wordmapIt->first contains a non-ASCII value, such as a character -105 occurring in the middle of a string. When this happens...
I think it is possible to write a TDI-Application with MFCs CPropertySheet class. Is this the right way to do it, or is there a standard way with not using this class?
It should also be possible to include a status-, menu- and toolbar into the application.
Thanks!
...
I just discovered that %ws was common knowledge (to some), for formatting unicode strings, as is %wZ - however msdn does not document these in a place I can find them. There are many people who write about these usefull printf format types individually on the web, but no official catch-all that I can find, and hence learn that they exist...
Is there a good algorithm for this? after an amount of searching around I haven't been able to find any conclusive answers.
Basically in a system which collects various bits of data about its users, each user is identified by a 64 bit unique Id. this Id is used as a primary key to a data set which may include any amount of data collecte...
How do you stop this force close??
Im trying to load a c++ ndk library called helloCpp but using the following code.
My program force closes as soon as it opens. I have checked that the libhelloCpp.so file is in the lib folder and it compiled with no errors.
//helloCpp.java
package com.knucklegames.helloCpp;
import android.app.Activity...
I'm having some problems defining some operator overloads for template classes. Let's take this hypothetical class for example.
template <class T>
class MyClass {
// ...
};
operator+=
// In MyClass.h
MyClass<T>& operator+=(const MyClass<T>& classObj);
// In MyClass.cpp
template <class T>
MyClass<T>& MyClass<T>::operator+=(const ...
Hello, my base class need to expose a method that for some derived classes would return a smart pointer to dynamically allocated array, and for some other derived classes would return a pointer/reference to statically allocated one.
example:
class Base
{
public:
virtual ??? foo()=0;
}
class A : public Base
{
private:
float ar...
I'm playing with X-development. I've got a basic proto-WM going that works for a while and then produces these errors after a fairly random time.
[edit]
Locking assertion failure. Backtrace:
#0 /usr/lib/libxcb-xlib.so.0 [0x7f71dcf9a9ac]
#1 /usr/lib/libxcb-xlib.so.0(xcb_xlib_unlock+0x24) [0x7f71dcf9aa54]
#2 /usr/lib/libX11.so.6 [0x7f71...
For a little library project I'm using boost::tuple. Right now, I'm facing the problem of turning a "cons list" I operated on via metaprogramming back to a boost::tuple<...> type. The "dirty" solution would be to provide lots of partial specialications a la
template<class T> struct id{typedef T type;};
template<class TL> struct type_li...