Vector, class, pointer

Hey guys, so I'm new with working with pointers and classes, and I'm trying to like a wine(in its own class) with a winery (another class). But I'm having some trouble, my program exits with the error segment core dump. I think it has something to do with the vectors not having enough room? but I cant figure out why exactly what is wrong. any help would be appreciated, let me know if you need to see any of my function definitions or anything else.

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
#include "Lab3.h"

int main () {


string n, t, wn, str, tow, stat,c, cont;

//double p;
printSignature();

vector<WineryName*> winName;
bool more = true;
while (more)
{
	cout << "Please enter the winery's name: (no to quit)";
	getline(cin, wn); 
		if (wn == "no") 
		{
		more = false;
		}
	else
	{
	winName.push_back(new WineryName(wn));
	}
}
vector<Wine*> wine;
more = true;
while (more) {
	cout << "Enter wine name " ;
	string n;
	getline (cin, n);
	if ( n =="no") more = false;
	else
	{
		Wine* wine = new Wine(n);
	string wineryname;
	cout << "enter the winerys name:";
	getline (cin, wineryname);
	wine->setWineryName(find(winName, wn));
	//wine.push_back(wine);                                    // Haveing trouble geting this to work as well
	}
}// program exits here (segment core dump)
cout << "youve made it out of the while loop";
for (int i = 0; i < 5; i++) {
	cout <<"youve made it to the for loop";
	wine[i]->print();
	cout << "wine index should have been printed";
}
	return 0;
}
Last edited on
Topic archived. No new replies allowed.