Hi Guys,

Im having issues with clearing an object of a class.

Currently I have 2 lists

class People
list<char> person
class School
list<people> teacher

i add the contects of person into people;

i read by executing the printChar function created in People whilst iterating in the School list.

itr -> printChar

the problem is that im getting the following issue it is printing like this

value 1 of list teacher = Marge
value 2 of list teacher = Marge + Homer
value 3 of list teacher = Marge + Homer + Bart.

This is because i havent cleared the object of class People when adding it to School.

HOW DO I DO THIS.
I have tried people student = new people(); But i get an error about 'void value not ignored as it ought to be'

i think

list::clear();

is what you're searching for. Read about it here

Click Me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.