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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:54:39+00:00 2026-06-14T10:54:39+00:00

I am written a c++ program and in it used array object and included

  • 0

I am written a c++ program and in it used array object and included <array> header file but when I try to compile it using g++ it return a lot of error messages saying that “array was not declared in this scope”. What can be wrong with it.
Program is here:

#include <iostream>
#include <string>
#include <array>

using namespace std;

const int Seasons = 4;
const array<string, Seasons> Snames =
 {"spring", "summer", "fall", "winter"};

void fill(array<double, Seasons>* pa);
void show(array<double, Seasons> da);

int main()
{
array<double, Seasons> expenses;
fill(&expenses);
show(expenses);

return 0;
}

void fill(array<double, Seasons>* pa)
{
 for(int i = 0; i < Seasons; i++)
 {
    cout << "Enter " << Snames[i] << " expenses: ";
    cin >> *pa[i];
 }
}

void show(array<double, Seasons> da)
{
double total = 0.0;
cout << "\nEXPENSES\n";

 for(int i = 0; i < Seasons; i++)
 {
    cout << Snames[i] << ": $" << da[i] << endl;
    total += da[i];
 }
cout << "Total Expenses: $" << total << endl;
}
  • 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-14T10:54:41+00:00Added an answer on June 14, 2026 at 10:54 am

    The most likely reason why your program does not compile is that the <array> header is not compatible with pre-C11 compilers. Add

    -std=c++0x
    

    to the flags of your g++ to enable C++11 support. Once you do, you’d get a different error, because line 28 should be

    cin >> (*pa)[i];
    

    (EDITED; original answer suggested a missing reference to std::)

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

Sidebar

Related Questions

Basically I've written this program to check for strings. I've used socket method for
I have written a C++ program for a University assignment. I used Netbeans 6.8
I have program written in C. It takes 2 arguments username/password and try to
Observe the following program written in Java (complete runnable version follows, but the important
That's my program written in C++ (OOP): #include <iostream> #include <string> using namespace std;
I Have a program written in VB6 that reads a long text file and
I have written a simple program that does autocorrelation as follows...I've used pgi accelerator
I have written a program which takes a file as input and whenever it
I have successfully written a video processing program. I used ubuntu and Netbeans for
I have written program in android for downloading from web server I have Used

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.