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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:03:12+00:00 2026-06-19T02:03:12+00:00

New to C++. Just making a simple struct/array program. Why can’t I pass an

  • 0

New to C++. Just making a simple struct/array program. Why can’t I pass an array of structs like I intend to here?

int NumGrads();

int main()
{
      struct Student {
          int id;
          bool isGrad;
      }; 

    const size_t size = 2;
    Student s1, s2;
    Student students[size] = { { 123, true },
                             { 124, false } };

    NumGrads(students, size);

    std::cin.get();
    return 0;
}

int NumGrads(Student Stu[], size_t size){

}

I appreciate that it must be something to do with passing by either reference or value, but surely if I’ve defined it in main(), I shouldn’t be getting an error with the parameter of NumGrads?

  • 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-19T02:03:13+00:00Added an answer on June 19, 2026 at 2:03 am

    Student is defined in main().
    Define it outside of main so that it’s in the same scope as NumGrads:

     struct Student
     {
          int id;
          bool isGrad;
     };
    
     int main()
     {
          ...
     } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple boost::any -like class for educational purposes, but I can't figure
I'm very new to WPF, so I've just started making a very simple Memory
Making just a simple basketball program where I ask for the home team name,
Fairly new to jquery so I might be making a simple mistake but I
I am making a simple CMS just for learning purposes and I have a
I have just started learning c# in xna and I'm making a simple tower
I'm new at Python and Pygame and I started making a simple game to
I am new to prototype, and I just made a simple example that won't
I'm trying to write a simple program to monitor a folder for new files
I am making a simple website that has a main text window with just

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.