I would like to use different instances of an STL custom allocator class to manage different memory spaces, and then be able to specify an allocator instance to an STL container such that each container only draws from its assigned memory space. But I don't see how I can do that. I see how I can pass an allocator type into the template...
Been trying to find this online for a while now.
I have a SDL_Surface with some content (in one it's text, in another is a part of a sprite). Inside the game loop I get the data onto the screen fine. But then it loops again and it doesn't replace the old data but just writes over it. So in the case of the text, it becomes a mess.
I've ...
How exactly do I do this in C/C++?
Let's say I want to shift int i twice to the left and store the value in f.
f = i << 2 ?
I don't need this for a program or anything, I'm just interested in how it works. Thanks.
...
So, for example, what would something like this:
lw $t1, 0($t0)
or
lw $t2, 8($t0)
Translate to in C or C++? I mean I'm loading a word from the address into a register, I get that. Is an array a similar concept, or, what?
Thanks in advance.
...
I have a open file dialog with three filters:
QString fileName = QFileDialog::getOpenFileName(
this,
title,
directory,
tr("JPEG (*.jpg *.jpeg);; TIFF (*.tif);; All files (*.*)")
);
This displays a dialog with "JPEG" selected as the default filter. I wanted to put the filter list in alphabetical order so...
Hi guys,
I'm able to read a string from a file but I'm having trouble deleting or emptying that string.
Thanks you for helping and have a great day.
#include <iostream>
#include <fstream>
#include <map>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;
int main() {
map<string, string> Data; // map of w...
Hello everyone,
Is there a quick and easy way of timing a section of a program (or the entire thing) without having to setup a timer class, functions, and variables inside my program itself?
I'm specifically referring to Visual C++ (Professional 2008).
Thanks,
-Faken
Edit: none of these answers do what i ask for, i would like to b...
I have a std::vector m_vPaths; I will iterate this vector and call ::DeleteFile(strPath) as I go. If I successfully delete the file, I will remove it from the vector. My question is can I get around having to use two vectors? Is there different data structure that might be better suited for what I need to do?
example:
using iterator...
I sort of understand this, at least the function of generators (I've used them in Python). I understand how the switch statement and its content is formed. However, I get these errors.
test.cpp: In constructor 'Foo::descent::descent(int)':
test.cpp:46: error: invalid use of nonstatic data member 'Foo::index_'
test.cpp: In member functi...
I'm having trouble implementing a nested class who's constructor is initialized with some of the enclosing class' private data members.
Example:
Header File:
class Enclosing {
//...Public members
//...Private members
int x, int y
class Inner; // Declaration for nested class
};
Impl. File:
// Stuff...
class Enclosing::Inner...
What does the following C++ code mean?
unsigned char a : 1;
unsigned char b : 7;
I guess it creates two char a and b, and both of them should be one byte long, but I have no idea what the ": 1" and ": 7" part does.
...
What are the best books on how to optimize C++ code?
...
i have make a c# form in csharp and i want to call it on visual c++.how would i call my forms in visual c++.please give me some sloution.
...
Hi All,
I am using gnuPlot library for printing a graph in C++ code. Its printing graph fine, but its printing only in blue color. Does somebody know how can I change the colors?
Cheers
...
//In header file: class definition:
class myString
{
public:
myString(void);
myString(const char *str);
myString(const myString &); //copy constructor
~myString(void); //destructor
void swap(myString &from);
private:
char *stringPtr;
int stringLen;
};
//in cpp file, defining them member fun...
I want to sort vector of certain struct with certain order in certain class. I've wrote definition of struct and predicate function in a class and run std::sort in a method of the class with these struct and function. But compilation error has occurred. gcc version is 4.0.1 and OS is Mac OSX. The code is following:
class sample {
public...
What's wrong with TextLayoutTransition? Can function pointers not be declared virtual?
LCDWrapper.h:23: error: function definition does not declare parameters
Here's the class.
class LCDInterface {
public:
// Slots
virtual void TextSetSpecialChars() = 0;
virtual void LayoutChangeBefore() = 0;
virtual void LayoutC...
I have an abstract class in my dll.
class IBase {
protected:
virtual ~IBase() = 0;
public:
virtual void f() = 0;
};
I want to get IBase in my exe-file which loads dll.
First way is to create following function
IBase * CreateInterface();
and to add the virtual function Release() in IBase.
Second way is to create a...
In the following code, what is the benefit of using (!!p) instead of (p != NULL)?
AClass *p = getInstanceOfAClass();
if( !!p )
// do something
else
// do something without having valid pointer
...
Hello,
AppActivate seems to be what i need, I am fairly sure there must be an c++/mfc equivalent.
Thanks.
...