/*
* main.cpp
*
*
* Created by Matthew Dunson on 12/7/09.
* Copyright 2009 The Ohio State University. All rights reserved.
*
*/
#include "matrix.h"
#include <iostream>
#include <fstream>
#include <string>
usingnamespace std;
int main (int argc, char *argv[])
{
string line;
ifstream file;
file.open (argv[1]);
int matrix_length;
getline (file, line);
matrix_length = atoi(line.c_str());
matrix matrixOne (matrix_length);
cout << matrixOne++ << endl;
cout << matrixOne << endl;
file.close ();
}
However, I get a bus error at run time. The error occurs when main executes line 27:
111
111
111
Bus error
I think it has something to do with how I'm implementing my increment operator, but I don't know what it is. Can you please help me (tell me what is wrong)?
Yeah, I did that on purpose (I don't know if it is right). Take the piece of code:
cout << matrixOne++ << endl;
According to the increment operation this would output the original value of matrixOne and then increment matrixOne. That's
why I am modifying matrixOne and returning a copy of it's original.