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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:36:56+00:00 2026-05-24T18:36:56+00:00

I need to create an operator that will copy the contents in one array

  • 0

I need to create an operator that will copy the contents in one array to another. A.K.A an equal operator. I am thinking something along these lines:

    operator=(string array[10][10], string array2[10][10])
    {
        int row = 0; int column = 0;
        for(column=0; column<=9; column++)
        {
            for(row=0; row<=9; row++){
                array2[row][column]=array[row][column];
            }
        }
    }

I am just not sure on the syntax of operator declarations which is my problem. I know how to make the inside code even if I got the code displayed above wrong. I am just not sure how to write the “operator=(string ….)”

  • 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-24T18:36:57+00:00Added an answer on May 24, 2026 at 6:36 pm

    You can’t. For two reasons

    • An array is a built in type, operator overloading is allowed only if at least one of the arguments is a user-defined type
    • operator = is one of the 4 operators (along with [], (), and ->) that have to be members of the class that they are overloaded for1. An array is not a class.

    What you can do is

    • Have a named function instead of operator

    • wrap the array into a class

    • use vector<vector<string> > which already has the assignment (<– my vote goes here)

    1As to why these have to be members, you can see this question of mine: Rationale of enforcing some operators to be members

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

Sidebar

Related Questions

I need to create an XML schema that looks something like this: <xs:element name=wrapperElement>
Need to create a custom DNS name server using C which will check against
I need to create a backup of a SQL Server 2005 Database that's only
I need to create a 2D int array of size 800x800. But doing so
I have a situation, where I need to create a new JavaScript object that
Lets say I have some domain objects that will need to be serialized/packed using
I am trying to create a base class that is a wrapper around std::array
I am trying to create an if statement that will perform an action if
I need create custom dialog and put JPanel into it. Is it possible?
i need create an email list sending to many emails. what is best solution

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.