This isn't an answer technically, I just revamped the code thus far, I'll add onto it later tonight if I have time. I just managed to put something together this morning, figured you might as well have a look so it doesn't just lay around doing nothing:
#include <iostream>
#include <vector>
#include <cstdarg>
class matrix{
public:
matrix(){};
matrix(std::initializer_list<std::vector<int>> vectors):x(vectors){}
~matrix(){};
const int& size(){ return this->x.size(); } //# of vectors
//ALT: ex. print: 3x3, 4x5, 7x3
//void size(){ std::cout<<"Dim: "<<this->x.size<<"x"<<this->x.front().size()<<std::endl;
void add(const std::vector<int>& arr){ this->x.push_back(arr); }
const std::vector<std::vector<int>>& extract(){ return this->x; } //Returns entire matrix
const std::vector<int>& getVector(const int& row){ return this->x.at(row); } //Returns specific vector from matrix
matrix operator*(const matrix& m){ //More params
//Stuff here
}
matrix operator*=(const matrix& m){ //More params
//Stuff here
}
private:
std::vector<std::vector<int>> x;
};
//Can break the center out to make one for vectors too
std::ostream& operator<<(std::ostream& os, matrix& m){
for (auto& it:m.extract()){
for (auto& jt:it){
os<<jt<<" ";
}
os<<std::endl;
}
os<<std::endl;
return os;
}
int main(){
matrix m({{2,5,8,11,14},
{3,6,9,12,15},
{4,7,10,13,16}});
std::cout<<m;
return 0;
}
This is, from what I gather, what the comments were about. Much easier to use in my opinion, though it may be something other than what you need if you are demanded to make structs and access vectors in some particular way.
Also, I didn't figure out what mathematical result you had in mind there, so I didn't put anything into the operators, I might add some crossproduct or dotproduct example later on, if that's what you were doing.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…