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

  • Home
  • SEARCH
  • 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 3313264
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:05:42+00:00 2026-05-17T22:05:42+00:00

i have two classes namely Flight and Runway . Now i am trying to

  • 0

i have two classes namely Flight and Runway. Now i am trying to pass an array of these objects as parameter to a function.

void fun(Flight ptr1[],Runway ptr2[])
{
...
...
}

ptr1 should point to an array of Flight objects and ptr2 should point to an array of Runway objects.
Now inside this function fun() how do i access members of these classes. Also can i use ptr1++ or ptr2++ to move between the objects??
Also how would i be calling this func??something like this –

Flight array1[5];
Runway array2[2];
fun(array1,array2);
  • 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-17T22:05:43+00:00Added an answer on May 17, 2026 at 10:05 pm
    void fun(Flight ptr1[],Runway ptr2[])
    

    is interpreted as

    void fun(Flight *ptr1, Runway *ptr2)
    

    This is called “decomposition,” and I think it’s rotten. It’s mainly a feature for backward compatibility with C. If you want pointers, specify pointers, not arrays, because pointers and arrays are different things.

    You can also do

    void fun(Flight (&arr1)[5], Runway (&arr2)[7])
    

    Now the parameters remain arrays inside the function, not pointers, so ++ arr1 is illegal and sizeof arr1/sizeof arr1[0] is 5. The argument arrays when you call the function also must be the correct size, exactly 5 and 7 respectively. In this context, & means pass-by-reference, so the arrays are not copied when you call the function.

    You can leverage the template system to generate a function for any size argument array, as well:

    template< size_t NF, size_t NR >
    void fun(Flight (&arr1)[NF], Runway (&arr2)[NR])
    

    Such a template may be called with any-sized arrays, and NF and NR will be integral constants set to the proper sizes.

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

Sidebar

Related Questions

I have two classes.... Parcel and FundParcel...and I'm trying to convert an IEnumerable of
I have two classes that I would like to merge into a composite. These
I have two classes one of which inherits from the other. Im trying to
I have two classes : import android.cla; public class CW { public static void
I have two classes Teacher and Student . I am trying to get teacher
I have two classes class PopulationMember { public: void operationOnThisMember1(); void operationOnThisMember2(); ... private:
I have two classes(Book,Software) that inherit from the Product class. these two classes have
I have two classes that each need an instance of each other to function.
I have two classes: Account and Operator. Account contains a list of Operators. Now,
I have two classes, namely User & UserProfile User contains(few attributes like):- userId loginId

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.