this is just a program that can no be compiled successfully. thus, could anyone provides a little advice for this. thanks
Code:// MMath.h : interface of the MMath class #pragma once #ifndef __MMATH_H__ #define __MMATH_H__ #include <iostream> #include <iomanip> #include <vector> #endif template <typename T, size_t R, size_t C> class YMatrix { // Constructor & Destructor public: YMatrix(); ~YMatrix(); // YMatrix(std::vector< std::vector<T> > & valv); // a overload constructor YMatrix(T (&arr)); // Operations public: //for test public: // YMatrix(T val); // T & operator=(T ori); void yout(); // void yset(T val); // members private: // std::vector< std::vector<T> > mem; // 2 dims vector for storing matrix data T test; // a private member variable for test program running T mem[R][C]; };Code:#include "mat.h" template<typename T, size_t R, size_t C> YMatrix<T,R,C>::YMatrix() { }; template<typename T, size_t R, size_t C> YMatrix<T,R,C>::~YMatrix() { }; template<typename T, size_t R, size_t C> void YMatrix<T,R,C>::yout() { for(int i=0; i<R; i++) { for(int j=0; j<C; j++) std::cout<<mem[i][j]; std::cout<<std::endl; } };Code:#include "mat.cpp" void test() { float ar[2][2] = {{1,2},{3.5,4.0}}; YMatrix<float, 2, 2> Ma(ar); Ma.yout(); } int main(void) { return 0; }



LinkBack URL
About LinkBacks



