Classes

I am writing my first class program. And for whatever reason, the error is coming up and saying Aborted (core dumped). Any idea why this error message is showing up?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <iostream>
#include <sstream>

class PrintClass
{
public: 
	PrintClass ()
	{	
		int board_numbers = 0; 
		for (int col = 0; col < board_size; col++)
		{
			for (int row = 0; row < board_size; row++)
			{
				std::ostringstream convert; 
				convert << board_numbers;   
				num_board[row][col] = convert.str();  
				board_numbers++; 
			}
		}
		for (int row = 0; row < board_size; row++)
		{
			for (int col = 0; col < board_size; col++)
			{
				sym_board[row][col] = " "; 
			}
		}
	};
	PrintClass (std::string, std::string)
	{

	}
	void printBoard (std::string *sym_board, std::string *num_board)
	{	 
		std::cout << std::endl;
		std::cout << "-"; 
		for (int j = 0; j < board_size; j++)
		{
		std::cout << "----";
		}
		std::cout << "    ";
		std::cout << "-"; 
		for (int j = 0; j < board_size; j++)
		{
		std::cout << "----";
		}
		std::cout << "    ";
		std::cout << std::endl;
		for (int i = 0; i < board_size; i++)
		{
			for (int j = 0; j < board_size; j++)
			{
				std::cout << "|";
				std::cout.width(3);
				std::cout << std::left << num_board[i][j]; 
			}
			std::cout << "|" << "    "; 
			for (int j = 0; j < board_size; j++)
			{
				std::cout << "|";
				std::cout.width(3);
				std::cout << std::left << sym_board[i][j]; 				
			}
			std::cout << "|" << std::endl;
			std::cout << "-"; 
			for (int j = 0; j < board_size; j++)
			{
			std::cout << "----";
			}
			std::cout << "    "; 
			std::cout << "-"; 
			for (int j = 0; j < board_size; j++)
			{
			std::cout << "----";
			}
			std::cout << std::endl; 
		}
	}
private: 
	std::string sym_board[14][14]; 
	std::string num_board[14][14]; 
	const static int board_size = 15; 
}; 

int main ()
{
	std::string sym_board[14][14];  
	std::string num_board[14][14]; 
	sym_board[0][0] ="x"; 
	num_board[1][1] = "o"; 
	PrintClass print; 


	return 0; 
}
Lines 79-81. Your loops iterate over board_size elements, but your arrays have only 14.
Topic archived. No new replies allowed.