cannot convert parameter 3

Here is my problem.
'void binary_tree::insert(int,int,char,char [],char [])' : cannot convert parameter 3 from 'const char [11]' to 'char'





The main function(part that have error)
1
2
3
4
5
6
7
8
9
10
void header(int n);
int main()
{
	header(2);
	binary_tree insert;
	insert.insert(342344, 89,"Binary Problem","Kenan", "Roge");
	insert.insert(23434234, 78,"Cyber World","Ann", "Sofie");
	insert.menu();
	return 0;
}
Last edited on
You cannot convert "Binary Problem" to char student_course.
student_course is a single character and "Binary Problem" is a pointer to a char.
Try char[] student_course instead of char student_course.
its like this char student_course[30]?
error C2440: '=' : cannot convert from 'char []' to 'char [50]'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void binary_tree::insert(int student_id, int grade, char student_course[50], char first[100], char last[100])
{
	if(root!=NULL)
		insert(student_id,grade,student_course,first,last,root);
	else
	{
		root=new record;
		root->student_id=student_id;
		root->grade=grade;
		root->student_course=student_course;
			strcpy(root->student_name,first);
			strcat(root->student_name,last);
		root->left=NULL;
		root->right=NULL;
	}
}
Did you alter your class declaration as well? Please show us the complete code.
void binary_tree::insert(int student_id, int grade, char student_course[50], char first[100], char last[100])
{
if(root!=NULL)
insert(student_id,grade,student_course,first,last,root);
else
{
root=new record;
root->student_id=student_id;
root->grade=grade;
root->student_course=student_course;
strcpy(root->student_name,first);
strcat(root->student_name,last);
root->left=NULL;
root->right=NULL;
}
}
Last edited on
In function binary_tree::insert() try
strcpy(root->student_course,student_course);
instead of
root->student_course=student_course;

And don't forget to free resources:

1
2
3
4
5
binary_tree::binary_tree()
{
	if(root)
		delete root;
}
Last edited on
Topic archived. No new replies allowed.