(C++) I've got a number of Entry classes, and got BaseProcessor interface which incapsulates Entry processing logic. (see code below)
The Entry doesn't provide operator<(). The BaseProcessor provides a pointer to less(Entry, Entry) function which is specific for particular BaseProcessor implementation.
I can use the function pointer to...
Hi,
How can I use find_if with a std::list if the list contains structs? My first pseudo code attempt at this looks like this:
typename std::list<Event>::iterator found =
find_if(cal.begin(), cal.last(), predicate);
The problem here is that the predicate is not directly visible in the list but inside event.object.return_number(...
Is there any benefit in starting a debug build without debugging (as opposed to a release build without debugging)? And what do I miss when I debug a release build (as opposed to debugging a debug build)?
...
Hi, there is a topic about this subject which is working with arrays but I can't make it work with matrices.
(Topic: http://stackoverflow.com/questions/312116/c-array-size-dependent-on-function-parameter-causes-compile-errors)
In summary:
long rows, columns;
cin >> rows >> columns;
char *a = new char [rows];
compiles grea...
It is possible to pass uninitialized object to a parent class like in the following example
class C
{
public:
C(int i):
m_i(i)
{};
int m_i;
}
class T
{
public:
T(C & c):
m_c(c)
{
};
C & m_c;
};
class ST : public T
{
public:
ST():
...
I have happened upon the following pattern, and wondered if there is a name for it?
An enum defines the concrete classes:
enum Fruits{ eApple, eBanana };
And a templated struct provides the interface:
template< Fruit T >
struct SomeFruit {
void eatIt() { // assert failure };
};
We can then implement the concrete classes thus:
...
Is there any possible way that a generic type can be used to contain a child of a base class.
From the assignment given to me, I am to create something similar to the following in structure.
template <class T>
class Fruit {
private:
int count;
int location_id;
T type;
public:
virtual void displayInfo();
};
class Ap...
Someone has given me the following C++ code snippet to try out - and now I have lost contact with them (its a long story). Anyway, it won't compile - I get an error
error C2512: 'mstream' : no appropriate default constructor available
Can anyone explain why, and what is needed to fix it.
class mstream : private ostream
{
public...
Hello!
Does someone know if the boost::get for the boost::variant is a performance-consuming operation or not.
Right now I am refactoring some old code in a performance-critical part, where "varianting" was implementing by containers for each possible types and corresponding enum.
Obviously, this is fast, but ugly and right now when I...
Hi,
I can't figure out a simple solution for the following problem:
I start with rotating, scaling and translating a AABB (lets call X) which will result in a OBB (lets call Y)
Now I want to figure out a new AABB (lets call Z) inside of the OBB (called Y) which fits best.
How can I solve this?
BTW: I know that there may exists mult...
Is there any advantage defining an array's size to be a multiple of 8, if using 64 bit UNIX OS? I am intended to use this array for loading data from shared memory. So dependencies may exist on the operating system and the page size.
...
A long time ago, I remember using some Solaris make, and they had an ingenious option that would automatically detect when the compiler options had changed, and rebuild all rules appropriately. For example, suppose I switch from:
g++ -O3
to
g++ -g
Then all files should be recompiled. I'm using gnu make, and haven't found any featu...
I've got an enum type defined in the private section of my class. I have a member of this type defined as well. When I try to initialize this member in the constructor body, I get memory corruption problems at run-time. When I initialize it through an initialization list in the same constructor instead, I do not get memory corruption pro...
How can I get the IP address of the system.
I want the Ip address as I can see after doing ipconfig or /bin/ifconfig
...
We all know the basic rules for static array:
int size = 20;
char myArray[size];
is not legal.
And.
const int size = 20;
char myArray[size];
is OK.
But, what about this.
int f(const int size)
{
char myArr[size];
}
void main()
{
f(2);
f(1024);
}
MSVC says it is an error, gcc seems to compile and execute it fine.
Obvi...
Possible Duplicate:
Digit limitation from decimal point in C++
What is the syntax to set numbers after the decimal point, not before it?
For example I have a value, "x.456" and I want to print only 1 number after the decimal point.
...
I want to store bits in an array (like structure). So I can follow either of the following two approaches
Approach number 1 (AN 1)
struct BIT
{
int data : 1
};
int main()
{
BIT a[100];
return 0;
}
Approach number 2 (AN 2)
int main()
{
std::bitset<100> BITS;
return 0;
}
Why would someone prefer AN 2 over AN 1?
...
I've run into some surprising behavior while using ADO with C++ and Microsoft SQL Server 2008 (express). Essentially, I had code that did this:
//pseudocode pseudocode pseudocode
adoConnection->Execute("BEGIN TRANSACTION;");
Insert( adoRecordsetPtr );
SelectAll( adoRecordsetPtr );
adoConnection->Execute("COMMIT TRANSACTION;");
But...
Hi all,
I have a file open on the iPhone that I am sending the data of across the network (Opened using "_open"). However I have the ability to delete files from the iphone's interface. This is done using NSFileManager's removeItemAtPath.
The odd thing is that removeItemAtPath is succeeding even though the file is currently open.
...
While I try the following:
system( "ifconfig -a | grep inet | "
"sed 's/\\([ ]*[^ ]*\\)\\([ ]*[^ ]*\\).*$/\\1 \\2/' "
" > address.txt" ) ;
I am getting the output in a file. How can I assign the out put to a variable.
...