954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

after a very unproductive day! - code bugs

This is gonna take some time, anyway here it is:

the student class :

[PHP]

#ifndef STUDENT_H
#define STUDENT_H

class Student
{
public:
Student(const char *, const char *, const Date&, const job&);
char * getfirstName();
char * getlastName();
void getbirthdate();
void getjobnumber();

private:

char firstname[25];
char lastname[25];

Date birthdate;
job jobnumber;
};

#endif

[/PHP]

the student class functions:


[PHP]

#include "student.h"

Student::Student(const char *first, const char *last, const Date &dateOfbirth, const job &jobs):birthdate(dateOfbirth), jobnumber(jobs)
{
strcpy(firstname , first );
strcpy(lastname, last);
} //constructor

char *Student::getfirstName()
{
return firstname;
}

char *Student::getlastName()
{
return lastname;
}


void Student::getbirthdate()
{
birthdate.getDate();
}


void Student::getjobnumber()
{
jobnumber.getjobnumber();
}

[/PHP]


the date class

[PHP]

#ifndef DATE_H
#define DATE_H

class Date
{
public:
Date(int = 1, int = 1 , int = 1900);
int getday();
int getmonth();
int getyear();
void getDate();

private:
int month, day, year;

};

#endif

[/PHP]


the date class functions:

[PHP]

#include "date.h"
Date::Date(int dy, int mn, int yr):month(mn), day(dy), year(yr)
{

}

int Date::getday()
{
return day;
}
int Date::getmonth()
{
return month;
}

int Date::getyear()
{
return year;
}


void Date::getDate()
{
cout << day << "/" << month << "/" << year;
}

[/PHP]

and now the new class that im trying to put in:

[PHP]


class job
{
public:
job(int = 1);
int getjob();
void setjob(int);
void printjob();
void getjobnumber():


private:

int jobnumber;

};

job::job(int a ) :jobnumber(a)
{
cout << "constructor call" << endl << "The value is :" << jobnumber;
}

int job::getjob()
{
cout << "job is: "<

using namespace std;

#include "date.h"
#include "job.h"
#include "student.h"

int main()
{
char firstname [25];
char secondname[25];

int day = 0, month = 0, year = 0;


cout << "\n\n --------------------------------------------------------------\n" <> day >> month >> year;

Date birth(day , month , year);

cout << "Please enter that students name" << endl;

job job1(1);

cin >> firstname >> secondname;

Student student1(firstname, secondname, birth, job1);

cout << "please enter there transaction number: "<

d:\extra programming\temp\class\student.h(5) : error C2236: unexpected 'class' 'Student'
d:\extra programming\temp\class\student.h(5) : error C2143: syntax error : missing ';' before '{'
d:\extra programming\temp\class\student.h(5) : error C2447: missing function header (old-style formal list?)
D:\extra programming\temp\Class\class2.cpp(35) : error C2065: 'Student' : undeclared identifier
D:\extra programming\temp\Class\class2.cpp(35) : error C2146: syntax error : missing ';' before identifier 'student1'
D:\extra programming\temp\Class\class2.cpp(35) : error C2065: 'student1' : undeclared identifier
D:\extra programming\temp\Class\class2.cpp(43) : error C2228: left of '.getfirstName' must have class/struct/union type
D:\extra programming\temp\Class\class2.cpp(43) : error C2228: left of '.getlastName' must have class/struct/union type
D:\extra programming\temp\Class\class2.cpp(45) : error C2228: left of '.getbirthdate' must have class/struct/union type
Error executing cl.exe.

looking at the code I cant see whats wrong! Everything works if i take away the job class and restore it. So its obviuosly nothing wrong with date class. Any ideas?

Acidburn
Posting Pro
511 posts since Dec 2004
Reputation Points: 12
Solved Threads: 5
 

>Everything works if i take away the job class
So the problem is with job.h and you can focus your debugging there. For example:

void getjobnumber()

Don't you think that should be:

void job::getjobnumber()

It's also a good idea to tell your compiler to produce preprocessed output so that you can make sure everything is kosher after it's all put together.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

whoopies. I'm gonna get to bed, perhaps spending a constant 6 -8 hours on the code isnt a good idea!! I'll begin debuggin 2moro

Acidburn
Posting Pro
511 posts since Dec 2004
Reputation Points: 12
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You