I have a structure:
typedef struct {
double x,y,z;
} XYZ;
I want to define a function like this:
double CalcDisparity(XYZ objposition,
XYZ eyeposition,
double InterOccularDistance = 65.0)
But I can't seem to find a way to assign a default value to eyeposition. How can I do this in C++...
Hello all,
I'm trying to do a simple custom runtime_error. I define the class:
#include <string>
#include <stdexcept>
namespace utils{
class FileNotFoundException: public std::runtime_error{
public:
FileNotFoundException():runtime_error("File not found"){}
FileNotFoundException(std::string msg):runtime_error(msg.c_str()){}
...
I'm grabbing a portion of the screen and scanning through the pixels for a certain color range.
I looked at MSDN's Capturing an Image example and know how to use the functions.
I can get the bits into an array, but I'm not sure how to do it in such a way that I can loop through it as I would an image. A pseudo-example (which I'm sure i...
how can i rewrite following pseudo code in c++?
real array sine_table[-1000..1000]
for x from -1000 to 1000
sine_table[x] := sine(pi * x / 1000)
i need create sine_table lookup table
...
Possible Duplicate:
An algorithm to decompose a whole number into all possible sets of whole numbers that sum to it.
An algorithm which for any input positive integer, gives all possible distinct arrays of positive non-zero integers that can sum to it.
e.g Inputting 4 returns (1,1,1,1), (1,1,2), (1,2,1), (2,1,1), (1,3), (3,1)...
Possible Duplicate:
Alternatives to Java for Android development?
I want to make apps for Android (Mobile OS) what other language(s) can i make them in EXCEPT java?
Thank you in advance ;-)
...
These are my variables:
const int sizeOfLicToCheckFor = 3;
string licNameToCheckFor[ sizeOfLicToCheckFor ] = { "PROF", "PERS", "PREM" };
when I run my program licNameToCheckFor is only initialized with "PROF" and nothing else.
What am I doing wrong?
...
is it possible to turn pipes genereated via pipe() on a POSIX-system into std::istreams and std::ostreams?
if yes, how?
i would prefer to use << and >> instead of read() and write()
thanks in advance
...
This is a copy of a question I asked on their forums and got no replies:
Having trouble finding information on making dialogs appear on the correct monitor when the parent is not on the main display. Currently I used wxDefaultPosition to initialize the dialog but this doesn't seem to play well with dual monitors (or more).
Is there so...
I have a few arrays and a resource that needs deletion, the value of these variables are retained throughout the lifetime of the program and they are only used in a single function so it naturally fits into static variables:
void func() {
static GLfloat arrs[4] = {1, 1, 1, 1};
static GLUquadric* quad = gluNewQuadric(); // delete...
I would like to have a function written in C, but callable from C++ which takes a restricted pointer. This is only available in c99, so g++ doesn't like it, even in extern "C" blocks. How can I get around this limitation?
...
I have this float which is a rotation angle.
Camera.roty += (float) diffx * 0.2;
where diff is the change in mouse position.
In OpenGL it will wrap it if it exceeds 360 or is below 0, but how could I do this if I want to verify if the angle is between 0 and 180?
Thanks
...
It reports An invalid handle was specified. for the code below:
if(hPipe)
CloseHandle(hPipe);
What can I do?
...
The documentation states that:
The Q_OBJECT macro must appear in the
private section of a class definition
that declares its own signals and
slots or that uses other services
provided by Qt's meta-object system.
But exactly what does that mean? On which QObject-derived classes can I safely omit it? Will problems arise if y...
In C++, is a const method returning a pointer to a non-const object considered bad practice? For example. consider the following methods:
// Makes perfect sense
bool isActive() const { return m_isActive; }
// Makes perfect sense, both consts ensure nothing is modified
const SomeObject* someObject() const { return m_someObject; }
// Ma...
I'm making a game that is entirely made of cubes. I notice that when I walk forward it runs lightening fast, but if I rotate the player in the opposite direction, its cripplingly slow. So what I did is ordered based on angle, but I still get some angles that are a bit slow. Here is how I did it:
I basically reverse iterate in certain an...
I'm trying to find a decent way to do logging from C++. My current solution is this:
ostream & GetLog() { if( output == NULL ) throw error; return *output; }
Where output is defined somewhere and can be a file or whatever. This is fine, but it doesn't let me do anything other than throw an error if output is not allocated. Also, my pr...
My game renders lots of cubes which randomly have 1 of 12 textures. I already Z order the geometry so therefore I cant just render all the cubes with texture1 then 2 then 3 etc... because that would defeat z ordering. I already keep track of the previous texture and in they are == then I do not call glbindtexture, but its still way too m...
Let's say I'm writing an interface for a class A that keeps a list of objects of type B, and I want to be able to manipulate that list through class A's interface. I could put add_B, remove_B, etc. methods to A's interface, but that's a lot of code duplication (this situation occurs in many classes in my programme), so I'd rather return...
Why does the following compile in C++?
int phew = 53;
++++++++++phew ;
The same code fails in C, why?
...