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









share|improve this question
























  • 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




    "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















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









share|improve this question
























  • 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




    "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













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









share|improve this question















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++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 7 at 22:38

























asked Nov 7 at 20:32









BENJA

11




11












  • 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




    "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








  • 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












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






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    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

























    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






    share|improve this answer

























      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






      share|improve this answer























        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






        share|improve this answer












        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







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 7 at 21:00









        user1178830

        18010




        18010






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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





















































            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







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()