Here I have made a piece of code that SHOULD display "firstname lastname"
The problem I have is that I does compile but the program itself doesnt work.
I dont see the problem but maybe you guys do.
Code:
#include <iostream.h>
#include <string.h>
class Student
{
friend void display(Student* s);
public:
int marks[5];
Student(char*fname,char*lname)
{
strcpy(fname,firstname);
strcpy(lname,lastname);
}
~Student()
{
}
protected:
int average[5];
char firstname[10];
char lastname[10];
};
void display(Student* s);
int main()
{
Student I("firstname","lastname");
display(&I);
return 0;
}
void display(Student* s)
{
cout<<s->firstname;
cout<<" ";
cout<<s->lastname;
}