Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6902765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:50:21+00:00 2026-05-27T07:50:21+00:00

I have this class: class Date { public: Date(); // Sets a date of

  • 0

I have this class:

class Date
{
public:
    Date();                                         // Sets a date of January 1, 2000
    Date(int mm, int dd, int yyyy);                 // Sets a date with the passed arguments; automatically converts two-digit years as being AFTER the year 2000
    Date after_period_of ( int days ) const;        // Elapses an arbitrary amount of time, and returns a new date
    string mmddyy () const;                         // Returns date in MM/DD/YY format (1/1/00)
    string full_date () const;                      // Returns date in full format (January 1, 2000)
    string month_name () const;                     // Returns the name of the month as a string;
private:
    int days_in_february(int yr);
    int month;
    int day;
    int year;
};

When I try to pass private variable year as an argument into days_in_february, I get the following error message:

passing ‘const Date’ as ‘this’ argument of ‘int Date::days_in_february(int)’ discards qualifiers

days_in_february is called in after_period_of, like this:

Date Date::after_period_of (int days_elapsed) const
{
    int new_month;
    int new_year = year;    // tried copying 'year' to get around this issue, but it did not help
    int days_into_new_month;
    int max_days_in_month[12] =  { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } ;
    max_days_in_month[1] = days_in_february(new_year);

and again in the same function:

if (new_month == 13)
            {
                new_month = 1;
                new_year += 1;
                max_days_in_month[1] = days_in_february(new_year);
            }

days_in_february simply returns the number 28 or 29 based on year that is passed into it. It does not attempt to manipulate anything outside of its own block.

I have even tried to pass a non-programmed variable into it (days_in_february(2000)) and I get the same error.I’ve tried moving that function into the public domain, but that didn’t fix the issue either.

Why is this happening?

Why am I not allowed to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:50:22+00:00Added an answer on May 27, 2026 at 7:50 am

    Inside after_period_of, you cannot access non-constant functions; in particular, you cannot access days_in_february. You can fix this by also declaring the latter function const.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JAXB class like this: public class Game { private Date startTime;
I have this class: public class StatInfo { public string contact; public DateTime date;
I have an object like this: class FanStruct{ public $date; public $userid; function __construct($date,
I have this Model public class SalesModelView { [Key] public int SaleId { get;
I have this class: public class CalendarData_Day { public DateTime Date { get; set;
I have this code: @Column(name = foo) @ReadTransformer(transformerClass=transformer.class) private Date foo; public static class
I have a report model looking a bit like this: class Report(models.Model): date =
I have this class called Table: class Table { public string Name { get
I have this class. public class Foo { public Guid Id { get; set;
I have this class: public static class CsvWriter { private static StreamWriter _writer =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.