Hi everyone,
I have run into a problem... I'm trying to use QTKit in an application that we have at work. The only problem with that is the app is written in C++, not Obj-C. I have looked through Apple's documentation for answers, but I haven't found anything useful.
Basically what I'm looking to do is write a single controller class i...
template <class Enum>
class EnumIterator {
public:
const Enum* operator-> () const {
return &(Enum::OfInt(i)); // warning: taking address of temporary
}
const Enum operator* () const {
return Enum::OfInt(i); // There is no problem with this one!
}
private:
int i;
};
I get this warning above. Currently I'm us...
Is there a better way to determine the length of an std::istream than the following:
std::istream* pcStream = GetSomeStream();
pcStream->seekg(0, ios::end);
unsigned int uiLength = pcStream->tellg();
It just seems really wasteful to have to seek to the end of the stream and then seek back to the original position, especially if the st...
Short of writing a function manually that translates a few known REFIID to names, such as:
if (riid == IID_IUnknown) return "IUnknown";
if (riid == IID_IShellBrowser) return "IShellBrowser";
...
Is there a system call that would return a reasonable debugging string for well-known (or even all) REFIIDs?
...
I'm not an experienced C++ programmer and I'm having problems compiling. I've got a Heap class that uses a template:
template <class T>
class Heap
{
public:
Heap(const vector<T>& values);
private:
vector<T> d;
// etc.
};
And then in a separate implementation file:
template <class T>
Heap<T>::Heap(const vector<T>& val...
Hi guys!
I must write array of struct Data to hard disk:
struct Data {
char cmember;
/* padding bytes */
int imember;
};
AFAIK, most of compilers will add some padding bytes between cmember and imember members of Data, but I want save to file only actual data (without paddings).
I have next code for saving Datas array (in ...
I see there are BN_CLICKED and BN_DBLCLK notification messages for a button control. but how would i catch a right click message for any button control?
...
I'm writing in C++ again after primarily using C# for the past couple of years. I've grown quite fond of the refactorings from VS and CodeRushXPress in addition to searching by reference (i.e. tabbing on a variable takes me to every instance of that variable, but not others named the same). The VS "find" just won't cut it :D. Can people ...
I have DLL, interface on C++ for work with he. In bcb, msvc it works fine. I want to use Python-scripts to access function in this library.
Generate python-package using Swig.
File setup.py
import distutils
from distutils.core import setup, Extension
setup(name = "DCM",
version = "1.3.2",
ext_modules = [Extension("_dcm", ...
Is it possilbe to get BOOST_STATIC_ASSERT to give a custom compilation error message? I belive the following is an attempt to do that in the code base I'm working in.
BOOST_STATIC_ASSERT( (MAX_NUMBER_OF_USERS == 15) && ("MAX_NUMBER_OF_USERS is no longer set to 15") );
Personally I'm not sure the error message gives anything - I'd rath...
Ok I have a school assignment to basically pick 3 memory leak detecting programs and run them on a bunch of c++ programs that the teacher supplies us and see how they compare to each other. These 3 programs have to be multi-platform and this is where I'm stuck. I have only been able to find one called valgrind which works on both MAC OSX...
From C++, are min and max preferable over fmin and fmax? For comparing two integers, do they provide basically the same functionality?
Do you tend to use one of these sets of functions or do you prefer to write your own (perhaps to improve efficiency, portability, flexibility, etc.)?
Notes:
The C++ Standard Template Library (STL) d...
let's say I have
std::map< std::string, std::string > m_someMap as a private member variable of class A
Two questions: (and the only reason I'm asking is because I came across code like that)
What's the purpose of this line:
A::A() : m_someMap()
Now I know that this is intialization, but do you have to do this like that?
I'm c...
Hello,
Today I wrote a small predicate to find matching symbols in a container.
But I'm faced to a problem: I want to use this predicate in a std::find_if call inside a const-method of a class, searching in a container that is a member of this class.
But I just noticed that neither std::find nor std::find_if are able to operate on con...
Hi,
I am basically wondering how C++ lays out the object in memory. So, I hear that dynamic casts simply asjusts the object's pointer in memory with an offset; and reinterpret kind of allows us to do anything with this pointer. I dont really understand this. Details would be appreciated!
Thanks.
...
I have a file - in a large legacy codebase - containing methods that access databases.
No classes are used, just a header file with the method declarations, and the source file with the implementation.
I want to override these methods to eliminate the DB access during unit testing.
I thought of the following options:
Make file into c...
I am trying to use ctags with VIM, and I am a newbie to both. In order to test the extent to which ctags could be useful I decided to put it through a very simple test, namely to parse the headers in /usr/include so that I could autocomplete some very basic functions.
When I run the command
ctags --c++-kinds=+p --fields=+iaS -f ~/.ta...
Does the standard guarantee that order of equal elements will not change (eh, forgot the term for that) by using std::sort or do I need to consider an alternative solution to achieve this goal?
...
The compiler (VC8) error is:
error C2680: 'std::_Tree<_Traits>::iterator' : invalid target type for dynamic_cast
the source code to simulate the error :
[EDIT]source fixed now
#include <map>
#include <string>
struct tag_data
{
int in;
int on;
std::string sn;
};
class myclass
{
private:
typedef std::map<std::string, tag...
Hello!
I have a project to create a program, which prevents the user from escaping a GUI program. The program is designed for students to take exams in. The program contains a web browser page.
I have looked around and asked in different places how I should do this, and I have been recommended Qt. I am now having second thoughts about ...