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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:24:41+00:00 2026-05-24T10:24:41+00:00

what is the difference between either of these used in a code as i

  • 0

what is the difference between either of these used in a code as i have used here.(line 44 ad line 45 both work fine)

Excerpt:

Date temp = *this;  //ASSIGNMENT OPERATOR CALL(PROVIDED BY COMPILER)
//Date temp(*this); //COPY CONSTRUCTOR CALL(PROVIDED BY COMPILER)

My Opinion : Is it that during assignment like object1 = object2; contents of object2 are deleted and placed in object1 while while if the same thing happens via a copy constructor contents of object2 still remain( i mean just as the word suggests “copy”).

NOTE: By the way my code compiled fine in Microsoft visual C++ 2008 but it gave a warning

  prog.cpp: In function ‘std::ostream& operator<<(std::ostream&, const Date&)’:
  prog.cpp:103: warning: deprecated conversion from string constant to 

in ideone.com.Any reasons for that.

  • 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-24T10:24:42+00:00Added an answer on May 24, 2026 at 10:24 am
    Date temp = *this; 
    Date temp(*this); 
    

    Both call copy constructor,
    First is called as Copy Initialization & second is called as Direct Initialization.

    Simple Rule to remember this is:
    If an object is getting created as well as initialized in the same statement then it calls Copy constructor.

    If an object is just assigned and not being created in the same statement then it calls Assignment(Copy Assignment) operator.


    The compiler complains because:

    An ordinary string literal has type “array of n const char”. And implicit conversion from const to non-const qualification for string literals (4.2) is deprecated.

    References:
    C++ Standard Section [2.13.4/2]:
    An ordinary string literal has type array of n const char, where n is the size of the string as defined below; it has static storage duration (3.7) and is initialized with the given characters.

    Annexure D section [D.4/1]
    The implicit conversion from const to non-const qualification for string literals (4.2) is deprecated.

    So to avoid the warning You should use:

    static const char *monthName[13]
          ^^^^^^^ 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The difference between Chr and Char when used in converting types is that one
What is actually the difference between these two casts? SomeClass sc = (SomeClass)SomeObject; SomeClass
I have a backend Dictionary that is used for synchronization (ie. to both a
What is the difference between these two methods that I believe do the same
I have two sets of vertexes used as a line strip: Vertexes1 Vertexes2 It's
Difference between a bus error and a segmentation fault? Can it happen that a
What is the difference between early and late binding?
Is there any difference between int on_exit(void (*function)(int , void *), void *arg); and
Is there a performance difference between i++ and ++i if the resulting value is
What is the difference between TrueType fonts and Type-1 fonts?

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.