Question

I don't understand why I keep getting this error, How do I fix it?

In file included from Chrono. cpp: 3:0: Chrono. h:50:22: error: Chrono Date& Chrono operator++ must have an argumen t of class or enumerated type Date& operator++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

you are defining an object which is not the member function of class Date.. Hence you should provide the object type as argument and then carryout member function operators in the function. You can't use d,y , m of the Date class in tjis function as it's not member function of Date,, Other way to do is declare operator++ as friend function of Date,but it also needs argument.

Given example

Date& operator++(Date &obj)
   {
       Date tmp;
       int d,y,m;
       d = obj.day();
       y = obj.year();
       m = obj.month();
       ++d;
       if (is_date == false)
       {
       d = 1;
       //if (m == dec)
       if ( m == 12)
       {
           //assign 1 for jan
       m = 1;
       ++y;
       }
       else
       {
       //m = obj.Month(int(m) + 1);
           obj.add_month(m + 1);
           m = obj.month();

       }
       }
       tmp.add_day(d);
       tmp.add_month(m);
       tmp.add_year(y);
       return tmp;
      
}

Add a comment
Know the answer?
Add Answer to:
I don't understand why I keep getting this error, How do I fix it? In file...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I keep getting this error and I do not know how to fix it. this is...

    I keep getting this error and I do not know how to fix it. this is the code I've been working on: please help me import java.util.*; public class TelephoneNumber { public static void main(String[] args) {String number; int i=0,j=0; char c; Scanner in=new Scanner (System.in); System.out.println("Enter the phone number: "); number=in.nextLine(); number=number.toUpperCase(); c=number.charAt(i); while(c!='\n'&&j<=7) {switch(c) {case 'A': case 'B': case 'C': System.out.print("2"); j++; break; case 'D': case 'E': case 'F': System.out.print("3"); j++; break; case 'G': case 'H': case'I': System.out.print("4");...

  • The following code has a problem with polymorphism. I keep getting a runtime error. Error: "An...

    The following code has a problem with polymorphism. I keep getting a runtime error. Error: "An unhandled exception of type System.InvalidCastException occured in polymorphism.exe" Apparently, I need one line of code to fix it. C# Code: class Sensor     {         private string sensorName;         public Sensor(string _name)         {             sensorName = _name;         }         public virtual void ActionType()         {             Console.WriteLine("Sensor Detect Nothing.");         } } class SmokeSensor : Sensor     {         private string type;...

  • Keep getting this error in my lab. Please help. Here is my cpp file and the...

    Keep getting this error in my lab. Please help. Here is my cpp file and the error given. Thank you 4 #include '10streat "Rationat . hi. .. Rational. cpp" 5 #include 6 :include Z using nanespace std 9 int sain) 11 char ch; 12 char op 13 Rational ri, r2, r3; 14 15 cout "nie lcome! I will evaluate expressions involving rational numbers for you 16 17 do 18 t 19 //Reading input 20 cout ee nEnter the expression (e.g.,...

  • Why does Thevenin's Theorem work? I understand how to use it but I don't understand why...

    Why does Thevenin's Theorem work? I understand how to use it but I don't understand why it works. I have been reading my textbook and can follow the procedure, but I want to understand on a deeper level why the author does what they do. So far I know that the steps are 1. Find Vth, the open terminal voltage 2. Find isc, the short circuit current Vth 3. Rth isc But I don't know why these steps work. I...

  • What are the H30+ OH and pOH of the solution I don't understand how I keep...

    What are the H30+ OH and pOH of the solution I don't understand how I keep getting the wrong answers but the right pH/pOH values Be sure to answer all parts. what are [H3O+], [OHT, and pH in a solution with a pOH of 3.46? IH,x 10 OH 1- pH 10.5 x10 M

  • Please help, I don't understand what I'm doing wrong because I keep getting .297uF but it...

    Please help, I don't understand what I'm doing wrong because I keep getting .297uF but it says it is wrong. Find the total capacitance of the combination of capacitors shown in the figure below. (C1 = 33.4 μF, C2 = 4.28 μF. Enter your answer to three decimal places.) 297 which capacitances would you consider first? Review definition of series and parallel combinations. μF C1 C2 0.300 μF

  • I have the attached code and keep getting an unexpected indent error on the last line,...

    I have the attached code and keep getting an unexpected indent error on the last line, how can I fix this? 1 import urllib 2 import re 3 url raw_input('Enter the URL:') 4 req request (url) 5 while True: 6 try: counts dict() fhandurllib.urlopen (req) for line in fhand: words line.split) for word in words: 10 counts[word] counts.get(word,0) 1 12 13 14 15 16 17 print(counts) data - count.getlength(512) if(len (data) < 1): break print data

  • "Function does not take 0 arguments". I keep getting this error for my last line of...

    "Function does not take 0 arguments". I keep getting this error for my last line of code: cout << "First Name: " << employee1.getfirstName() << endl; I do not understand why. I am trying to put the name "Mike" into the firstName string. Why is my constructor not working? In main it should be set to string firstName, string lastName, int salary. Yet nothing is being put into the string. #include<iostream> #include<string> using namespace std; class Employee {    int...

  • Can someone please help me. i keep getting an error in my code. I need it...

    Can someone please help me. i keep getting an error in my code. I need it to be on three seperate files! attached is my assignment and my code. c++ The class date Type implements the date in a program. Write the class functions as specified in the UML class diagram. The values for the month, day, and year should be validated (in the class functions) before storing the date into the data members. Set the invalid member data to...

  • Unable to find out why am I getting: Account.java:85: error: reached end of file while parsing...

    Unable to find out why am I getting: Account.java:85: error: reached end of file while parsing import java.util.*; class Account{ private int id; private double balance; private double annualInterestRate; private Date dateCreated; public Account() { id = 0; balance = 0; annualInterestRate = 0; dateCreated = new Date(); } public Account(int id1, double balance1) { id =id1; balance = balance1; dateCreated = new Date(); } public void setId(int id1) { id=id1; } public void setBalance(double balance1) { balance = balance1;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT