[size] cxx0030 error expression cannot be evaluated HELP!!!

when I compile and run it, the first input and any input with the same ID works, however if I ]try a new input the program breaks right after the add() function is called

when I choose to stop the execution VC++ opens xstring source file and says that the break occurs in the following function

1
2
3
4
size_type size() const
{	// return length of sequence
	return (this->_Mysize);
}







1
2
3
4
5
6
7
8
9
void Brain::interact(){	

	string id, op, prop;

	cin >> id >> op >> prop;
		
	add(id, op, prop);

}


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
int Brain::add(string id, string op, string prop){					

	std::cout<< "add() started\n";	// this is where the program seems to stop, I dont think if statements aren't evaluated						

	if (idExist(id)){									
 
		kNode *currentNode = knowledgeList.firstNode;

		int listLength = knowledgeList.getLength();

		for (int counter = 0; counter < listLength; counter++){

			if (id == currentNode->getId()){

				currentNode->Data.addProperty(prop);
				currentNode->Data.addOperator(op);
				
				std::cout << id << "\n";
				std::cout <<currentNode->Data.operators.firstNode->getData()<<"\n";
				std::cout << currentNode->Data.properties.firstNode->getData()<< "\n";
				
				return 1;

			}

			currentNode = currentNode->nextNode;

		}

	}
	else{
		
		std::cout<<"next level\n";

		knowledgeList.add(id);		

		kNode *currentNode = knowledgeList.firstNode;

		int listLength = knowledgeList.getLength();

		for (int counter = 0; counter < listLength; counter++){

			if (id == currentNode->getId()){

				currentNode->Data.addProperty(prop);
				currentNode->Data.addOperator(op);

				std::cout << id << "\n";
				std::cout <<currentNode->Data.operators.firstNode->getData()<<"\n";
				std::cout << currentNode->Data.properties.firstNode->getData()<< "\n";
							
				return 1;

			}

			currentNode = currentNode->nextNode;

		}

	}

	return 0;

}


also if I look at the statement that broke I get this

[size] CXX0030: Error: expression cannot be evaluated
[capacity] CXX0030: Error: expression cannot be evaluated

if you would like to see any supporting code just ask,
Last edited on
First thing I might suggest is make sure your data is getting in and out of the parameters as expected. If that is working fine start stepping through the code of Add and see where the problem really is the next step. I am betting the logic isn't right in one half or the other, or the calling function.

When I see errors like those, they usually mean something was empty or null. In other words when I entered text, did I get any data in at all or did I get something that looked like garbage?
Thank you!!! I stepped through the functions that are used and it turns out that in a function called getLength() on line 39 was supposed to iterate through the list until it got to the end, and return the number of elements, turns out that I forgot to put

currentNode = currentNode->nextNode;

thanks again
Topic archived. No new replies allowed.