daviddoria 334 Posting Virtuoso Featured Poster

beautiful! thanks!

daviddoria 334 Posting Virtuoso Featured Poster

beautiful! thanks!

daviddoria 334 Posting Virtuoso Featured Poster

you nailed it... sorry for the stupid question.

daviddoria 334 Posting Virtuoso Featured Poster

I have "right" overloading working fine with:

Vector Point::operator*( double P )

this would be called with MyPoint*2 and gives the results I would like. However, if I say:

2*MyPoint, it says I can't do that. Makes sense, but surely this can be done! I had trouble googling because I didn't know what to call this!

Any help will be appreciated!

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I have a class called Point.

Point.h :

#ifndef POINT_H
#define POINT_H

#include "Vector.h"
#include <iostream>

class Point
{
	friend ostream& operator<<(ostream& output, const Point& p) //must have global scope
	{
		output << "x: " << x << " y: " << y;
		return output;
	}

The compiler is telling me
syntax error: Missing ';' before '&'

Am I doing something wrong?

Thanks!

Dave

daviddoria 334 Posting Virtuoso Featured Poster

What I was saying was the compiler did not complain that I did NOT have #ifndef - shouldn't it have?
Other than that I think I'm good to go!

daviddoria 334 Posting Virtuoso Featured Poster

So basically all that is different is you put the functions in a cpp file?

I replaced

Point Vector::GetPoint()

with

Point GetPoint()

is that not a good idea?

Also, you include the headers in the Vector.cpp and Point.cpp AND in program.cpp - doesn't that mean you need to have #ifndef statements?

Thanks for the help!

daviddoria 334 Posting Virtuoso Featured Poster

I have a class Vector that needs to have a function that returns type Point, and a class Point that needs to have a function that returns type Vector.

I was informed that I needed to use forward references, which I thought I had implemented as follows. I am still getting this error: use of undefined type 'Vector'

Here are my files:

Point.h

class Vector;

class Point
{

public:
	Vector GetVector()
	{
		Vector A;
		return A;
	}
};

Vector.h

class Point;

class Vector
{

public:
	Point GetPoint()
	{
		Point A;
		return A;
	}
};

Program.cpp

#include <iostream>

#include "Point.h"
#include "Vector.h"

using namespace std;

void main()
{
	Point P;
	Vector V;
}

Surely this is a very easy problem and I am just doing something silly. Please let me know.

Thanks!

Dave

daviddoria 334 Posting Virtuoso Featured Poster

well apparently not EVERYone because it doesn't let me do what I want...

daviddoria 334 Posting Virtuoso Featured Poster

Is it possible to make a function with an unknown number of parameters without knowing ANY of them?

ie.
void Test(...)

I know you could do
void Test(va_alist)
with varargs.h, doesn't make sense that this functionality has been removed does it?

Thanks!

Dave

daviddoria 334 Posting Virtuoso Featured Poster

but how do you make the color transitions smooth - ie. how to ensure the colors run through the reds first before switching to the mix of red green before switching to the green... etc. ?

ie the colors dont go in order like some sort of binary thing. 0 0 0 is not necessarily followed by 0 0 1, etc.

Am I wrong about this?

Thanks,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Is there a way to interpolate between RGB values? I have a set of values that I want to map (linearly or otherwise) to colors from a color_min RGB triple to a color_max RGB triple. Since RGB is not "incrementable", how would I do this?

Thanks,

David