Jump to content
  • Advertisement
Sign in to follow this  

Quick help

This topic is 4962 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This matrix class is a little screwy, it is displaying weird numbers
#include <iostream>
#include <cstddef>
#include <vector>

template<typename T> class matrix
    matrix(std::size_t r = 4, std::size_t c = 4, T val = T())
    	: rows(r), columns(c)
   	    for (std::size_t k = 0; k < rows; k++) 
   	        for (std::size_t j = 0; j < columns; j++) 
    friend std::ostream& operator<<(std::ostream& out, const matrix& m)
        for (std::size_t k = 0; k < m.rows; k++) 
   	        for (std::size_t j = 0; j < m.columns; j++)
   	        	out << m.rows_vec[k][j] << ' ';
       	    out << '\n';
    std::vector<T>& operator[](std::size_t i) { return rows_vec; }
    const std::vector<T>& operator[](std::size_t i) const { return rows_vec; }
    std::size_t rows, columns;
    std::vector<T> cols_vec;
    std::vector<std::vector<T> > rows_vec;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!