| bmafaul (9) | |
|
#include <iostream> #include <stdio.h> using namespace std; class Student { char *studname; int studnum; char gender; public: void setstudname(char*); void setstudnum(int); void setgender(char); char getstudname(); int getstudnum(); char getgender(); }; void Student::setstudname(char *sd) { int i; for(i=0; i<strlen(sd); i++) { if(!isalpha(sd[i])) { break; } } if(i=strlen(sd)) { studname=sd; } else { studname = "toot"; }; char *Student::getstudname() { return studname; } void Student::setstudnum(int sn) { if(sn >= 1 && sn <= 9) { studentnumber=sn; } } int Student::getstudnum() { return studentnumber; } void Student::setgender(char sg) { if(toupper(sg) == 'M' || toupper(sg) == 'F') { gender = sg; } else { gender = 'B'; } } char Person::getGender() { return gender; } whats wrong with this program? can you help me guys.. . | |
|
|
|
| James Grider (24) | |
| Are you getting an error? | |
|
|
|
| garob (72) | |||||
|
Please use code tags, it makes it much easier to read and improves your chances of getting help. First error I found when compiling your code is strlen is not defined, add #include <cstring> to your includes.Add a closing brace before
The function
To fix all the errors check the definitions and declarations match and all opening braces have matching closing braces, the easiest way is to indect. | |||||
|
Last edited on
|
|||||
| bmafaul (9) | |
| tnx :)) | |
|
|
|