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 8823819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:27:13+00:00 2026-06-14T06:27:13+00:00

This is the complete error message: error: cannot convert ‘MyTime’ to ‘const MyTime*’ for

  • 0

This is the complete error message:

error: cannot convert ‘MyTime’ to ‘const MyTime*’ for argument ‘1’ to ‘int DetermineElapsedTime(const MyTime*, const MyTime*)’|

And this is my code:

#include <iostream>
#include<cstdlib>
#include<cstring>

using namespace std;
struct MyTime { int hours, minutes, seconds; };
int DetermineElapsedTime(const MyTime *t1, const MyTime *t2);
const int hourSeconds = 3600;
const int minSeconds = 60;

int DetermineElapsedTime(const MyTime *t1, const MyTime *t2)
{
    long timeDiff = ((((t2->hours * hourSeconds) + (t2->minutes * minSeconds) + t2->seconds) -
                   ((t1->hours * hourSeconds) + (t1->minutes * minSeconds) + t1->seconds)));
    return(timeDiff);
}


int main(void)
{
    char delim1, delim2;
    MyTime tm, tm2;
    cout << "Input two formats for the time. Separate each with a space. Ex: hr:min:sec\n";
    cin >> tm.hours >> delim1 >> tm.minutes >> delim2 >> tm.seconds;
    cin >> tm2.hours >> delim1 >> tm2.minutes >> delim2 >> tm2.seconds;

    DetermineElapsedTime(tm, tm2);

    return 0;

}

Is there any way that I can fix? Please feel free to point out any other errors that you see. I do know about fixing DetermineTimeElapsed to properly output the hr:min:sec format. but right now I need to get past 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-06-14T06:27:14+00:00Added an answer on June 14, 2026 at 6:27 am

    The error should be at below line:

    DetermineElapsedTime(tm, tm2);
    

    You are passing MyTime objects to the above function when it expects const MyTime*.

    Fix it by either passing the object addresses:

    DetermineElapsedTime(&tm, &tm2);
    

    Or better C++ way: by changing the function prototype to accept object references:

    int DetermineElapsedTime(const MyTime &t1, const MyTime &t2);
    

    the body also will change accordingly; e.g. -> will be replaced by . operator and so on.

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

Sidebar

Related Questions

With regards this example from Code Complete: Comparison Compare(int value1, int value2) { if
This is the complete source code: http://www.sendspace.com/file/lwxpyf I have a problem with a JSF
I am getting this weird error message can not sort on multivalued field: fieldname
I'm not sure if this is possible (complete non-flash developer speaking), but we have
This query takes about 52 seconds to complete. It appears 82% of the time
This query takes ~4 seconds to complete: SELECT DISTINCT resources_resource.id, resources_resource.heading, resources_resource.name, resources_resource.old_name, resources_resource.clean_name,
I am complete newbie for programming and this is my first real program I
Forgive the complete newbie question here - I know this is really basic stuff,
This is the first time, I am involved in writing a complete client for
I'm trying to complete my assignment and this is the last thing to do

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.