How can I correct my program and make it display the initial time as intended
up vote
-4
down vote
favorite
I'm trying to make a programming that would set the time to 11/7/2018, but it's not working. It only display 4 errors. Can someone please help me rectify the code.
#include <iostream>
using namespace std;
class date {
private:
int day,month,year;
public:
void advance();
date(){
day=1;
month=1;
year=2018;
};
void setDate(){
cout<<day<<"/"<<month<<"/"<<year<<endl;
}
};
void date::advance(){
for(month=1;month=<12;month++){
for(day=1;day=<31;day++){
cout<<day<<"/"<<month<<"/"<<year<<endl;
}
}
}
int main(){
date d;
cout<<"Date set as:";
d.setDate();
cout<<"Setting the advance method"<<endl;
d.advance();
return 0;
}
It display In member function void date::setDate()
:
[Error] expected primary-expression before '<<' token
In member function 'void date::advance()':
[Error] expected primary-expression before '<<' token
c++
add a comment |
up vote
-4
down vote
favorite
I'm trying to make a programming that would set the time to 11/7/2018, but it's not working. It only display 4 errors. Can someone please help me rectify the code.
#include <iostream>
using namespace std;
class date {
private:
int day,month,year;
public:
void advance();
date(){
day=1;
month=1;
year=2018;
};
void setDate(){
cout<<day<<"/"<<month<<"/"<<year<<endl;
}
};
void date::advance(){
for(month=1;month=<12;month++){
for(day=1;day=<31;day++){
cout<<day<<"/"<<month<<"/"<<year<<endl;
}
}
}
int main(){
date d;
cout<<"Date set as:";
d.setDate();
cout<<"Setting the advance method"<<endl;
d.advance();
return 0;
}
It display In member function void date::setDate()
:
[Error] expected primary-expression before '<<' token
In member function 'void date::advance()':
[Error] expected primary-expression before '<<' token
c++
You are usingdate
which isn't declared. You probably meant to useday
. Also, as was pointed out by a now deleted comment, you should verify that you use=
(assignment) correctly (comparison for equality would use==
).
– Dietmar Kühl
Nov 7 at 21:00
1
"it's not working. It only display 4 errors" is not a useful problem description. At the very least, show us the errors.
– Jesper Juhl
Nov 7 at 21:02
1
@JesperJuhl: I agree that the formatting isn't ideal but it does say[Error] expected primary-expression before '<<' token
...
– Dietmar Kühl
Nov 7 at 21:03
add a comment |
up vote
-4
down vote
favorite
up vote
-4
down vote
favorite
I'm trying to make a programming that would set the time to 11/7/2018, but it's not working. It only display 4 errors. Can someone please help me rectify the code.
#include <iostream>
using namespace std;
class date {
private:
int day,month,year;
public:
void advance();
date(){
day=1;
month=1;
year=2018;
};
void setDate(){
cout<<day<<"/"<<month<<"/"<<year<<endl;
}
};
void date::advance(){
for(month=1;month=<12;month++){
for(day=1;day=<31;day++){
cout<<day<<"/"<<month<<"/"<<year<<endl;
}
}
}
int main(){
date d;
cout<<"Date set as:";
d.setDate();
cout<<"Setting the advance method"<<endl;
d.advance();
return 0;
}
It display In member function void date::setDate()
:
[Error] expected primary-expression before '<<' token
In member function 'void date::advance()':
[Error] expected primary-expression before '<<' token
c++
I'm trying to make a programming that would set the time to 11/7/2018, but it's not working. It only display 4 errors. Can someone please help me rectify the code.
#include <iostream>
using namespace std;
class date {
private:
int day,month,year;
public:
void advance();
date(){
day=1;
month=1;
year=2018;
};
void setDate(){
cout<<day<<"/"<<month<<"/"<<year<<endl;
}
};
void date::advance(){
for(month=1;month=<12;month++){
for(day=1;day=<31;day++){
cout<<day<<"/"<<month<<"/"<<year<<endl;
}
}
}
int main(){
date d;
cout<<"Date set as:";
d.setDate();
cout<<"Setting the advance method"<<endl;
d.advance();
return 0;
}
It display In member function void date::setDate()
:
[Error] expected primary-expression before '<<' token
In member function 'void date::advance()':
[Error] expected primary-expression before '<<' token
c++
c++
edited Nov 7 at 22:38
asked Nov 7 at 20:32
BENJA
11
11
You are usingdate
which isn't declared. You probably meant to useday
. Also, as was pointed out by a now deleted comment, you should verify that you use=
(assignment) correctly (comparison for equality would use==
).
– Dietmar Kühl
Nov 7 at 21:00
1
"it's not working. It only display 4 errors" is not a useful problem description. At the very least, show us the errors.
– Jesper Juhl
Nov 7 at 21:02
1
@JesperJuhl: I agree that the formatting isn't ideal but it does say[Error] expected primary-expression before '<<' token
...
– Dietmar Kühl
Nov 7 at 21:03
add a comment |
You are usingdate
which isn't declared. You probably meant to useday
. Also, as was pointed out by a now deleted comment, you should verify that you use=
(assignment) correctly (comparison for equality would use==
).
– Dietmar Kühl
Nov 7 at 21:00
1
"it's not working. It only display 4 errors" is not a useful problem description. At the very least, show us the errors.
– Jesper Juhl
Nov 7 at 21:02
1
@JesperJuhl: I agree that the formatting isn't ideal but it does say[Error] expected primary-expression before '<<' token
...
– Dietmar Kühl
Nov 7 at 21:03
You are using
date
which isn't declared. You probably meant to use day
. Also, as was pointed out by a now deleted comment, you should verify that you use =
(assignment) correctly (comparison for equality would use ==
).– Dietmar Kühl
Nov 7 at 21:00
You are using
date
which isn't declared. You probably meant to use day
. Also, as was pointed out by a now deleted comment, you should verify that you use =
(assignment) correctly (comparison for equality would use ==
).– Dietmar Kühl
Nov 7 at 21:00
1
1
"it's not working. It only display 4 errors" is not a useful problem description. At the very least, show us the errors.
– Jesper Juhl
Nov 7 at 21:02
"it's not working. It only display 4 errors" is not a useful problem description. At the very least, show us the errors.
– Jesper Juhl
Nov 7 at 21:02
1
1
@JesperJuhl: I agree that the formatting isn't ideal but it does say
[Error] expected primary-expression before '<<' token
...– Dietmar Kühl
Nov 7 at 21:03
@JesperJuhl: I agree that the formatting isn't ideal but it does say
[Error] expected primary-expression before '<<' token
...– Dietmar Kühl
Nov 7 at 21:03
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
I think you meant to write
cout<<day<<"/"<<month<<"/"<<year<<endl;
instead of
cout<<date<<"/"<<month<<"/"<<year<<endl;
in both the setDate and advance functions
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
I think you meant to write
cout<<day<<"/"<<month<<"/"<<year<<endl;
instead of
cout<<date<<"/"<<month<<"/"<<year<<endl;
in both the setDate and advance functions
add a comment |
up vote
1
down vote
I think you meant to write
cout<<day<<"/"<<month<<"/"<<year<<endl;
instead of
cout<<date<<"/"<<month<<"/"<<year<<endl;
in both the setDate and advance functions
add a comment |
up vote
1
down vote
up vote
1
down vote
I think you meant to write
cout<<day<<"/"<<month<<"/"<<year<<endl;
instead of
cout<<date<<"/"<<month<<"/"<<year<<endl;
in both the setDate and advance functions
I think you meant to write
cout<<day<<"/"<<month<<"/"<<year<<endl;
instead of
cout<<date<<"/"<<month<<"/"<<year<<endl;
in both the setDate and advance functions
answered Nov 7 at 21:00
user1178830
18010
18010
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53197368%2fhow-can-i-correct-my-program-and-make-it-display-the-initial-time-as-intended%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You are using
date
which isn't declared. You probably meant to useday
. Also, as was pointed out by a now deleted comment, you should verify that you use=
(assignment) correctly (comparison for equality would use==
).– Dietmar Kühl
Nov 7 at 21:00
1
"it's not working. It only display 4 errors" is not a useful problem description. At the very least, show us the errors.
– Jesper Juhl
Nov 7 at 21:02
1
@JesperJuhl: I agree that the formatting isn't ideal but it does say
[Error] expected primary-expression before '<<' token
...– Dietmar Kühl
Nov 7 at 21:03