hey, i am working on this project, and have made it to the end of the hard coding part. Now i need to work out the bugs / get the thing to compile. I am having some trouble though as i am getting error messages that i dont understand.

here is the code that i am having issues with:

//in matrix.h
template <class T>
ostream& operator<<(ostream& out, Matrix<T>& m)
{
	m.output(out);
	return out;
}

//problem occurs when this is run:
out << "-m6 = " << -m6 << endl;

and here is the error that i am getting:

MatrixTest.cpp - In function `int main()': 
166 - MatrixTest.cpp - no match for 'operator<<' in 'std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(&std::cout)), ((const char*)"-m6 = ")) << Matrix<T>::operator-() const [with T = int]()'

those are the big ones that are giving me issues. thanks for your help!!

mattwaab;


p.s. in the zip folder, the project is in the folder called "project"

How much code do you write before pressing compile?

10 lines?
100?
1000?
Never write so much code that you can't deal with the compiler spitting it all out as a pile of crap. It's much better that you find this out early (like 2 minutes after you wrote it).

//problem occurs when this is run:
out << "-m6 = " << -m6 << endl;
The problem with this line is that it isn't inside a function.

<fx>waits for the inevitable - oh, I edited it for brevity, and completely changed the problem in doing so</fx>

The problem with that line is not that it is in not in function but this:

You have defined

template <class T>
ostream& operator<<(ostream& out, Matrix<T>& m)
{
  m.output(out);
  return out;
}

BUT you need to use it in a context that requires const Matrix& since you are returning Matrix<T> from operator-() . You can fix the problem by adding const to the Matrix<T>& part.

p.s. I wish I hadn't downloaded the file and looked...

Please consider that 1e-16 != 0 . Now think hard, how is that going to effect your code.

There are other things but .... fix the base first.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.