Wyswietlanie dwuwymiarowego vectora

0

Witam, mam pytanie jak wyświetlać vector dwuwymiarowy? Mam coś takiego, ale nie działa

 
vector<vector<cMatrix>> vec;
void cMatrix::wyswietl()
{
for( auto v=vec.begin(); v!=vec.end(); ++v)
{
	for (auto w=v->begin(); w!=v->end(); ++w)
		cout<<w;
}
}
3
#include <vector>
#include <iostream>

using namespace std;

int main() {
    vector<vector<int>> table = {
        {1, 2, 3},
        {4, 5, 6},
        {7, 8, 9}
    };
    
    for(auto const &row: table) {
        for(auto el: row) {
            cout << el << " ";
        }
        cout << endl;
    }
}

http://melpon.org/wandbox/permlink/U5mz4nFoShccrhCY

0

Dziękuje
A da się to zrobić w sposób podobny do przedstawionego przeze mnie? ;)

0

tak.

0

error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::vector<_Ty>' (or there is no acceptable conversion)

class cMatrix
{
	int kolumny;
	int wiersze;

public:
	vector<vector<int>> vec;
	void wyswietl();
	void rozmiar();
	void uzupelnij();
	cMatrix();
	cMatrix(int a, int b);
	cMatrix (const cMatrix & M);
};
 
 
void cMatrix::wyswietl()
{
	for( auto v=vec.begin(); v!=vec.end(); ++v)
	{
		for (auto w=v->begin(); w!=v->end(); ++w)
			cout<<*v;
		cout<<endl;
	}

}
void cMatrix::uzupelnij()
{
	int tmp;
	for(int i = 0; i<kolumny; i++)
	{
		for (int j = 0 ; j<wiersze; j++)
		{
			cin>>tmp;
			vec.push_back( vector <int>( tmp ) );
		}
	}
}
void cMatrix::rozmiar()
{
	cout<<"Podaj ilosc kolumn: ";
	cin>>kolumny;
	cout<<"Podaj ilosc wierszy: ";
	cin>>wiersze;
}
cMatrix::cMatrix (const cMatrix & M)

1 użytkowników online, w tym zalogowanych: 0, gości: 1