Getting a break in for loop

I am getting a break, ignore, continue warning for my program indicating the place Line 113. Anyone knows why this is happening and how to solve it?
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282

//iAccount.h
#ifndef SICT_IACCOUNT_H__
#define SICT_IACCOUNT_H__

#include <iostream>

namespace sict {

	class iAccount {
	public:
	
		virtual bool credit(double) = 0;

	
		virtual bool debit(double) = 0;

	
		virtual void monthEnd() = 0;

		
		virtual void display(std::ostream&) const = 0;
	};

	
	iAccount* CreateAccount(const char*, double);
}
#endif

//SavingsAccount.h
#ifndef SICT_SAVINGSACCOUNT_H__
#define SICT_SAVINGSACCOUNT_H__

#include "Account.h"

namespace sict {
	class SavingsAccount : Account {


	public:
		
		SavingsAccount(double, double);

	
		void monthEnd();

				
		void display(std::ostream&);
	};
}
#endif

//Account.cpp
#include "Account.h"
namespace sict {
	Account::Account() {
		m_balance = 0;
		m_rate = 0;
	}

	Account::Account(double balance) {
		if (balance > 0) {
			m_balance = balance;
		}
		else {
			m_balance = 0;
		}
	}
	bool Account::credit(double credit) {
		if (credit > 0) {
			m_balance += credit;
			return true;
		}
		else {
			return false;
		}
	}
	bool Account::debit(double debit) {
		if (debit > 0) {
			m_balance -= debit;
			return true;
		}
		else {
			return m_balance;
		}
	}
	double Account::balance() const {
		return m_balance;
	}

}

//Main.cpp
#include <iostream>
#include <cstring>
#include "iAccount.h" 

using namespace sict;
using namespace std;

// display inserts account information for client
//
void display(const char* client, iAccount* const acct[], int n) {
	int lineLength = strlen(client) + 22;
	cout.fill('*');
	cout.width(lineLength);
	cout << "*" << endl;
	cout << "DISPLAY Accounts for " << client << ":" << endl;
	cout.width(lineLength);
	cout << "*" << endl;
	cout.fill(' ');
	for (int i = 0; i < n; ++i) {
		acct[i]->display(cout);
		if (i < n - 1) cout << "-----------------------" << endl;
	}
	cout.fill('*');
	cout.width(lineLength);
	cout << "****************************" << endl << endl;
	cout.fill(' ');
}

// close a client's accounts
// 
void close(iAccount* acct[], int n) {
	for (int i = 0; i < n; ++i) {
		delete acct[i];
		acct[i] = nullptr;
	}
}

int main() {
	// Create Accounts for Angelina
	iAccount* Angelina[2];

	// initialize Angelina's Accounts
	Angelina[0] = CreateAccount("Savings", 400.0);
	Angelina[1] = CreateAccount("Savings", 400.0);
	display("Angelina", Angelina, 2);

	cout << "DEPOSIT $2000 into Angelina Accounts ..." << endl;
	for (int i = 0; i < 2; i++)
		Angelina[i]->credit(2000);

	cout << "WITHDRAW $1000 and $500 from Angelina's Accounts ... " << endl;
	Angelina[0]->debit(1000);
	Angelina[1]->debit(500);
	cout << endl;
	display("Angelina", Angelina, 2);

	Angelina[0]->monthEnd();
	Angelina[1]->monthEnd();
	display("Angelina", Angelina, 2);

	close(Angelina, 2);
}

//SavingsAccount.h
#ifndef SICT_SAVINGSACCOUNT_H__
#define SICT_SAVINGSACCOUNT_H__

#include "Account.h"

namespace sict {
	class SavingsAccount : Account {


	public:
		
		SavingsAccount(double, double);

		
		void monthEnd();

				
		void display(std::ostream&);
	};
}
#endif

//Account.h
#ifndef SICT_ACCOUNT_H__
#define SICT_ACCOUNT_H__

#include "iAccount.h"

namespace sict {

	class Account {
		double m_balance;


	protected:
		double balance() const;
		double m_rate;
	public:
		Account();

		Account(double);

		bool credit(double);

	
		bool debit(double);
	};


}
#endif

//Account.cpp
#include "Account.h"
namespace sict {
	Account::Account() {
		m_balance = 0;
		m_rate = 0;
	}

	Account::Account(double balance) {
		if (balance > 0) {
			m_balance = balance;
		}
		else {
			m_balance = 0;
		}
	}
	bool Account::credit(double credit) {
		if (credit > 0) {
			m_balance += credit;
			return true;
		}
		else {
			return false;
		}
	}
	bool Account::debit(double debit) {
		if (debit > 0) {
			m_balance -= debit;
			return true;
		}
		else {
			return m_balance;
		}
	}
	double Account::balance() const {
		return m_balance;
	}

}

//Allocator.cpp
#include "SavingsAccount.h" 
#include <cstring>
namespace sict {

	// define interest rate
	//
	const int intRate = 0.05;


	
	//
	iAccount* CreateAccount(const char* string, double balance) {
		for (int i = 0; i<strlen(string); i++) {
			if (string[0] == 'S') {
				SavingsAccount*	dynamicAccount = new SavingsAccount(balance, intRate);
				//dynamicAccount = new char [strlen(string)];
			}
			else {
				return nullptr;
			}
		}

	}








}


Last edited on
Nothing is returned from the CreateAccount function.
How would I return it so that it returns its address to the calling function?
Just return the pointer, same as you would any other type of value.

I'm surprised your compiler didn't warn you about the fact that you have a function that doesn't always return a value.
Topic archived. No new replies allowed.