| | |
class type
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jan 2007
Posts: 67
Reputation:
Solved Threads: 0
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;
}
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;
}
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.
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.
¿umop apisdn upside down? ![]() |
Similar Threads
- Object or Class Type Required? (Delphi) (Pascal and Delphi)
- missing storage-class or type specifiers error (C++)
- Compiling a Class in several parts?!? (C++)
- Visual Studio 6: Initializing static class member (C++)
- "missing storage-class or type specifiers" error (C++)
- struct type redefinition (C++)
Other Threads in the C++ Forum
- Previous Thread: Permutation
- Next Thread: C++ Date Class
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node output parameter pointer problem program programming project proxy python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





