Crash Help

I'm trying to make an templated class of List and trying to make a list of Students(another class) which I made. Its not working.
Code seems to work fine for pre-defined data types but it crashes when it comes to students. I also want to run sort function on list of students.
Last edited on
1
2
3
4
5
6
7
8
9
	Student(char *n = 0, int r = 0)
	{
		rollno = r;
		name = new char[strlen(n) + 1];
		for(int i = 0; i < strlen(n)+1; i++)
		{
			name[i] = n[i];
		}
	}
If you create an `Student' by doing Student foo; you'll try to dereference a null pointer in `strlen()'

In your list you do list = new p[size];
that would construct `size' students passing NULL as parameter.

http://www.cplusplus.com/forum/general/112111/
Topic archived. No new replies allowed.