944,084 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 1161
  • C++ RSS
Jul 18th, 2007
0

class type

Expand Post »
Hi
What is wrong with that piece of code.Why it doeasn't let me compile. It gives me that errors on Dev-C++ :
15 expected primary-expression before "void"
15 ISO C++ forbids declaration of `privite' with no type
15 expected `;' before "void"
In member function `void DayOfYear::input()':
45 `check_date' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
At global scope:
49 no `void DayOfYear::check_date()' member function declared in class `DayOfYear'
In member function `void DayOfYear::set(int, int)':
67 `check_date' undeclared (first use this function)



#include<iostream>
#include<conio.h>
using namespace std;
class DayOfYear
{
public:
void input();
void output();
void set(int new_month, int new_day);
int get_month();
int get_day();
privite:
void check_date();
int month;
int day;
};
int main()
{
DayOfYear today,bach_birthday;

cout<<"Enter todays date: ";
today.input();
cout<<"Todays date is :";
today.output();
bach_birthday.set(3,21);
if (today.get_month()==bach_birthday.get_month()&&today.get_day()==bach_birthday.get_day())
cout<<"Happy birthday Bach ";
else
cout<<"Happy unbirthday Bach";


getch();
return 0;
}
void DayOfYear::input()
{
cout<<"Enter the month as a number: ";
cin>>month;
cout<<"Enter the day of the month: ";
cin>>day;
check_date();
}
void DayOfYear::check_date()
{
if ((month<1)||(month>12)||(day<1)||(day>31))
{
cout<<"Illigal date. Aborting program.\n)";
exit(1);
}
}
void DayOfYear::output()
{
cout<<"The month is: "<<month;
cout<<"\nThe day is: "<<day;
}

void DayOfYear::set(int new_month,int new_day)
{
month=new_month;
day=new_day;
check_date();
}
int DayOfYear::get_month()
{
return month;
}
int DayOfYear::get_day()
{
return day;
}
Similar Threads
Reputation Points: 20
Solved Threads: 0
Junior Poster in Training
mauro21pl is offline Offline
66 posts
since Jan 2007
Jul 18th, 2007
0

Re: class type

Quote ...
15 ISO C++ forbids declaration of `privite' with no type
The error says it all. private is misspelled.
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Jul 18th, 2007
0

Re: class type

When saw that error first thing I thought is misspelling, but check it yourself. Did you try to compile it? This can't be misspelling.
Thanks
Reputation Points: 20
Solved Threads: 0
Junior Poster in Training
mauro21pl is offline Offline
66 posts
since Jan 2007
Jul 18th, 2007
0

Re: class type

Quote ...
Did you try to compile it? This can't be misspelling.
I just did to be sure. I got the same errors and changing privite to private fixed everything.
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Jul 18th, 2007
0

Re: class type

o yeee. thats right, all the time i thought about the member function name. That explain everything. thanks a lot
Reputation Points: 20
Solved Threads: 0
Junior Poster in Training
mauro21pl is offline Offline
66 posts
since Jan 2007
Jul 18th, 2007
0

Re: class type

Whenever you're trying to track a whole list of compiler errors, Always look to fix the first error in the list (usually found on the line of the first error, or the line just before the first error) , then try a recompile before fixing any more.

The reason behind this method, very often, just one small mistake can have a knock-on effect, producing a ton of other "phantom" error messages. (ie, error messages which aren't actually errors, and exist only as a result of the compiler being confused by the initial error).


Another tip - use the little-and-often approach to compiling.. ie, write a few lines, then try to compile.. This minimises the chance of getting a long list of errors, but also immediately narrows down the location of the errors when they occur - if everything was working fine on the previous compile, and all you've done is change 1 line of code, you can bet any money the error will be on that line.
Last edited by Bench; Jul 18th, 2007 at 6:34 pm.
Reputation Points: 307
Solved Threads: 62
Posting Pro
Bench is offline Offline
565 posts
since Feb 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Permutation
Next Thread in C++ Forum Timeline: TUpDown on TStringGrid in c++ builder?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC