In my programs infinity usually arises when a value is divided by zero. I get indeterminate when I divide zero by zero. How do you check for infinite and indeterminate values in C++?
In C++, infinity is represented by 1.#INF. Indeterminate is represented by -1.#IND. The problem is how to test if a variable is infinite or indeterminate. ...
Hi,
I'm trying to create an overridden operator function using both const parameters, but I can't figure out how to do it. Here is a simple example:
class Number
{
Number()
{
value = 1;
};
inline Number operator + (const Number& n)
{
Number result;
result.value = value + n.value;
re...
What harm can come from defining BOOST_DISABLE_ABI_HEADERS when compiling boost?
From the boost file: boost_1_37_0\boost\config\user.hpp
// BOOST_DISABLE_ABI_HEADERS: Stops boost headers from including any
// prefix/suffix headers that normally control things like struct
// packing and alignment.
//#define BOOST_DISABLE_ABI_HEADERS...
i want a specialize template in a pointer-to-member-function case. Is there a way to detect this? right now i declare struct isPtrToMemberFunc, then add an extra template (class TType=void) to each class (right now just 1) and specialize the extra template to see if its isPtrToMemberFunc. Is there a way to detect this automatically? if n...
I have a function with the same name, but with different signature in a base and derived classes. When I am trying to use the base class's function in another class that inherits from the derived, I receive an error. See the following code:
class A
{
public:
void foo(string s){};
};
class B : public A
{
public:
int foo(...
I'm used to thinking of member functions as just being a special case of normal functions, where member functions have an extra parameter at the beginning of their parameter list for the 'this' pointer, that is, the object on which the member function is supposed to act. I've used boost::function this way in the past and never encountere...
In Visual Studio (C++), is there a way to easily find duplicate headers that are defined in .cpp files?
I'm also trying to find ways to detect this situation:
A includes B includes C
A includes C
=> A doesn't need to include C
...
Has anyone used Hudson as a Continuous-Integration server for a C++ project using UnitTest++ as a testing library?
How exactly did you set it up?
I know there have been several questions on Continuous Integration before, but I hope this one has a narrower scope.
EDIT: I'll clarify a bit on what I'm looking for. I already have the buil...
Does anyone know a good resource or some pointers which could help me make a side scrolling tile based (descreet movement for character) with box pushing and moving platforms etc. I'm focused right now C/C++ console development (tho after this project I may stop and do stuff a little more graphical, still C/C++). Something bit like Super...
Hi,
i'm using this example implementation found at http://tangentsoft.net/wskfaq/examples/basics/select-server.html
This is doing most of what I need, handles connections without blocking and does all work in its thread (not creating a new thread for each connection as some examples do), but i'm worried since i've been told winsock wil...
Hello, I'm reading some code in the Ogre3D implementation, and I can't understand what does a void*-typed variable could mean. What does a pointer to void means in C++?
...
I'm just learning QT with C++. I have successfully implemented signals and slots to trap standard events like ButtonPushed(), etc. However, I want to have a function called when I mouse over and mouse out of a QLabel. It looks like QHoverEvent will do what I need, but I can't seem to find any tutorials or examples on how to implement thi...
A pointer stores/is assigned a memory address;
what about a reference variable?
it stores the actual value of an object just like any other non-pointer simple variables on Stack?
Thanks!
...
Hi everyone, I've been learning C++, coming from C#, where I've gotten used to using service providers: basically a Dictionary<Type, object>. Unfortunately, I can't figure out how to do this in C++. So the questions are basically:
How would I make a dictionary in C++.
How would I use 'Type' with it, as far as I know there is no 'Type' ...
I want to convert function object to function.
I wrote this code, but it doesn't work.
#include <iostream>
typedef int (*int_to_int)(int);
struct adder {
int n_;
adder (int n) : n_(n) {}
int operator() (int x) { return x + n_; }
operator int_to_int () {
return this->*&adder::operator();
}
};
int main(void...
I know downcasting like this won't work. I need a method that WILL work. Here's my problem: I've got several different derived classes all from a base class. My first try was to make an array of base class. The program has to select (more or less at random) different derived classes. I had tried casting from a base class to the derived c...
I'm working on a document application and part of this application I've to add support to read the keyboard pressed events and replace the pre-defined characters set if that keyboard entry is match with the pre-defind short form/word.The actual application has implemented in C++.
Please provide me your thoughts on how to implement this....
I come from a C++ background where I can use template mixins to write code that refers to FinalClass which is a template parameter that is passed in. This allows reusable functions to be "mixed-in" to any derived class, by simply inheriting from ReusableMixin with a template paramter of MyFinalClass. This all gets inlined into the clas...
Is there a way to undefine the += on strings and wstrings for chars and wchar_t?
Basically I want to avoid bugs like the following:
int age = 27;
std::wstring str = std::wstring(L"User's age is: ");
str += age;
std::string str2 = std::string("User's age is: ");
str2 += age;
The above code will add the ascii character 27 to the stri...
I have the following use case, a struct with some boolean and int variables
struct a {
int field1;
bool field2;
bool field3;
};
I am refactoring this code, and writing a constructor for the struct , the problem is the default initialization of fields.
I am not criticizing any language construct here, but ideally I woul...