#include <iostream>
#include <cstring>
using namespace std;
class date
{
public:
date(int = 1, int = 1, int = 1990); //constructor
void Printdate();
void setday(int);
void setmonth(int);
void setyear(int);
void setdate(int, int, int);
private:
int day, month, year;
};
date::date(int d, int m, int y)
{
setdate(d,m,y);
}
void date::setdate(int dd, int mm , int yy )
{
day = dd;
month = mm;
year = yy;
}
void date::Printdate()
{
cout << day << "/" << month << "/" << year <<endl;
}
void date::setday(int dd)
{
day = dd;
}
void date::setmonth(int mm)
{
month = mm;
}
void date::setyear(int yy)
{
year = yy;
}
class Student
{
public:
Student(); //constuctor for student class
void setName(char );
void PrintName();
date Printdate();
private:
char student[20]; // array to store name.
};
Student::Student()
{
strcpy(student, "Acidburn");
}
void Student::PrintName()
{
cout << student<<endl;
}
void Student::setName(char N)
{
strcpy(student , " N ");
}
int main(void)
{
int day = 0, month = 0, year = 0;
char student[20]; // array to hold students name.
date date1;
Student St1;
cout << "Before call to set day" << endl;
date1.Printdate(); //shows default values from consturctor
cout << " ----------------------------------------------------\n";
cout << "Please enter your student details" <<endl;
cin >> student;
St1.setName("student");
return 0;
}
Now the problem is with the student class ... In main I've declared an array of char student[20]; . I ask the user to enter the name in main. Anyway on passing the student information to the class to write to the private array data. I get an error
D:\extra programming\temp\class.cpp(103) : error C2664: 'setName' : cannot convert parameter 1 from 'char [8]' to 'char'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Error executing cl.exe.
Can anyone point me in the direction for fixing it?
Thanks