• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About Yeshu

  • Rank
  1. Cant get my matrix to print correctly

    figuredit out
  2. My matrix wont print correctly Im loading it from a dat file and all i get our empy spaces. Can anyone help? #include <iostream.h> #include "apmatrix.h" #include <fstream.h> #include<iomanip.h> int x; int y; char secret; apmatrix <char> matrix(6,6,0); int main() { ifstream infile; ifstream infile_alpha; infile.open("alpha.dat", ios::in); for(x=0;x<=5;x++) { for(y=0;y<=5;y++) { infile_alpha>>secret; matrix[x][y]=secret; } } cout<<setw(3); for(x=0;x<=5;x++) { for(y=0;y<=5;y++) { cout<<setw(3)<<matrix[x][y]; } } system("PAUSE"); return 0; }
  3. how do I load alpha.dat into my matrix? and thanks for helping
  4. So I have to print a dat file to the screen using a matrix. Here is the code I have so far and I consistently get 25 errors. I have tried putting the apmatrix.h file int he include folder and adding the apmatrix.cpp files to the project and nothing works. When I wrote this program in the classroom I got it to compile but nothing printed to the screen. Any help #include <iostream.h> #include "apmatrix.h" #include <fstream.h> int main() { apmatrix <char> secret(6,6); ifstream infile; ifstream infile_alpha; infile.open("alpha.dat", ios::in); cout<< secret; system("PAUSE"); return 0; } ERRORS ______________________ Compiler: Default compiler Building Makefile: "C:\Dev-Cpp\Makefile.win" Executing make... make.exe -f "C:\Dev-Cpp\Makefile.win" all g++.exe -D__DEBUG__ -c apmatrix.cpp -o apmatrix.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -g3 In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31, from C:/Dev-Cpp/include/apvector.cpp:16, from C:/Dev-Cpp/include/c++/3.4.2/backward/apvector.h:127, from C:/Dev-Cpp/include/c++/3.4.2/backward/apmatrix.h:4, from apmatrix.cpp:12: C:/Dev-Cpp/include/c++/3.4.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. apmatrix.cpp:18: error: redefinition of `apmatrix<itemType>::apmatrix()' C:/Dev-Cpp/include/apmatrix.cpp:18: error: `apmatrix<itemType>::apmatrix()' previously declared here apmatrix.cpp:29: error: redefinition of `apmatrix<itemType>::apmatrix(int, int)' C:/Dev-Cpp/include/apmatrix.cpp:29: error: `apmatrix<itemType>::apmatrix(int, int)' previously declared here apmatrix.cpp:45: error: redefinition of `apmatrix<itemType>::apmatrix(int, int, const itemType&)' C:/Dev-Cpp/include/apmatrix.cpp:45: error: `apmatrix<itemType>::apmatrix(int, int, const itemType&)' previously declared here apmatrix.cpp:68: error: redefinition of `apmatrix<itemType>::apmatrix(const apmatrix<itemType>&)' C:/Dev-Cpp/include/apmatrix.cpp:68: error: `apmatrix<itemType>::apmatrix(const apmatrix<itemType>&)' previously declared here apmatrix.cpp:86: error: redefinition of `apmatrix<itemType>::~apmatrix()' C:/Dev-Cpp/include/apmatrix.cpp:86: error: `apmatrix<itemType>::~apmatrix()' previously declared here apmatrix.cpp:96: error: redefinition of `const apmatrix<itemType>& apmatrix<itemType>::operator=(const apmatrix<itemType>&)' C:/Dev-Cpp/include/apmatrix.cpp:96: error: `const apmatrix<itemType>& apmatrix<itemType>::operator=(const apmatrix<itemType>&)' previously declared here apmatrix.cpp:116: error: redefinition of `int apmatrix<itemType>::numrows() const' C:/Dev-Cpp/include/apmatrix.cpp:116: error: `int apmatrix<itemType>::numrows() const' previously declared here apmatrix.cpp:123: error: redefinition of `int apmatrix<itemType>::numcols() const' C:/Dev-Cpp/include/apmatrix.cpp:123: error: `int apmatrix<itemType>::numcols() const' previously declared here apmatrix.cpp:140: error: redefinition of `void apmatrix<itemType>::resize(int, int)' C:/Dev-Cpp/include/apmatrix.cpp:140: error: `void apmatrix<itemType>::resize(int, int)' previously declared here apmatrix.cpp:157: error: redefinition of `const apvector<itemType>& apmatrix<itemType>::operator[](int) const' C:/Dev-Cpp/include/apmatrix.cpp:157: error: `const apvector<itemType>& apmatrix<itemType>::operator[](int) const' previously declared here apmatrix.cpp:172: error: redefinition of `apvector<itemType>& apmatrix<itemType>::operator[](int)' C:/Dev-Cpp/include/apmatrix.cpp:172: error: `apvector<itemType>& apmatrix<itemType>::operator[](int)' previously declared here make.exe: *** [apmatrix.o] Error 1 Execution terminated
  • Advertisement