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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:55:21+00:00 2026-06-01T23:55:21+00:00

I have run into this situation I find really tricky. I have 2 classes:

  • 0

I have run into this situation I find really tricky. I have 2 classes: time12 and time24 which maintain time on a 12 hr and 24 hr basis respectively. Both of them are supposed to have individual conversion functions to handle conversions to the other type. But if I declare time 12 first, then the “time24” in the prototype of the conversion function will be undefined as the time24 class will be declared later. So what do I do now? I can’t even only declare it inside and define it after the 2nd class. So now what?

class time12
{
 operator time24()  //time24 is undefined at this stage
 {

 }
};

class time24
{

};
  • 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-01T23:55:22+00:00Added an answer on June 1, 2026 at 11:55 pm

    Normally in c++ you have 2 types of files, .h and .cpp. Your .h file is your declaration, and .cpp is your definition.

    Example:

    convtime.h:

    #ifndef CONVTIME_H_ //this is to prevent repeated definition of convtime.h
    #define CONVTIME_H_
    
    class time24; //for the operator in class12
    
    class time12
    {
    public:
        time12(int); //constructor
        operator time24();
    private:
        //list your private functions and members here
    }
    
    class time24
    {
    public:
        time24(int); //constructor
    private:
        //list your private functions and members here
    }
    
    #endif //CONVTIME_H_
    

    convtime.cpp:

    #include "convtime.h"
    
    //constructor for time12
    time12::time12(int n)
    {
        //your code
    }
    
    //operator() overload definition for time12
    time24 time12::operator()
    {
        //your code
    }
    
    //constructor for time24
    time24::time24(int n)
    {
        //your code
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I seem to run into this situation quite a lot and have yet to
I have run into this problem a few times and I'm not happy with
NOTE: I have solved the majority of this problem but have run into a
Ok so this is a brand new snag I have run into. I am
I have run into a situation where I want to ensure that a compound
I have a client program based on LibCurl. I have run into a situation
I have run into these problems several times and was never able to find
I have run into a situation where I need to manually remove old dialogs
I have run into a couple of similar quirks regarding uint usage in both
I have run into a problem trying to modify a form I myself have

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.