Debug

can someone please help me debug this?
// Function displays course information
// instructor defaults to Staff
// enrollment defualts to 30
#include<iostream.h>
#include<conio.h>

void main()
{
void displayCourseInfo(char instructor[] = "Staff", int enrollment = 30, char course[]);
displayCourseInfo("ENG101");
displayCourseInfo("Bossert", "PSY151");
displayCourseInfo("Dykeman", 24, "CIS200");

getch();
}

void displayCourseInfo(char course[], char instructor[], int enrollment)
{
cout<<course<<" taught by "<<instructor<<" enrollment "<<enrollment<<endl;
}
For default parameter see:

http://en.cppreference.com/w/cpp/language/default_arguments

This
displayCourseInfo("Bossert", "PSY151");
cannot work because the second parameter needs to be an int.

Compare:
void displayCourseInfo(char instructor[] = "Staff", int enrollment = 30, char course[]);
with:
1
2
3
4
void displayCourseInfo(char course[], char instructor[], int enrollment)
{
cout<<course<<" taught by "<<instructor<<" enrollment "<<enrollment<<endl;
}


Read this (especially 'Declaring functions'):

http://www.cplusplus.com/doc/tutorial/functions/
still a bit unclear sorry.
Topic archived. No new replies allowed.