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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:17:20+00:00 2026-05-31T12:17:20+00:00

OK so I have made a class called Courses with private member functions courseName,

  • 0

OK so I have made a class called Courses with private member functions courseName, creditHours,grade, and courseNumber.

Since this is homework and we just went over pointers and dynamic memory allocation,
I have to read in how many courses the student has taken, dynamically create an array of Course type, and prompt the user to enter information regarding the courses. This is how the instructor wants it done.

Below is the function I have for creating and filling the array but I am unsure of how to actually fill it.

Course readCourseArray(int coursesTaken)
{
    cout<<"\nHow many courses has the student taken?\n";
    cin>>coursesTaken;

    Course *courses = new Course[coursesTaken];

    for(int count = 0; count < coursesTaken; count++)
        {
            cout<<"Enter name for course "<<count+1<<endl;
            getline(cin,courses[count].courseName);
            }

    return *courseArray;

}

My problem is the getline portion. I get a red squiggle and it says courseName is inaccessible and I cant think of another way to run through the loop.

In my class specification file I have

void setCourseName (string _courseName)
{courseName=_courseName;};

But I don’t know how I would use that to cycle through the array either.

  • 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-31T12:17:21+00:00Added an answer on May 31, 2026 at 12:17 pm

    It looks like courseName is a private member variable. private means you can’t access it outside of the class. To use getline, create a temporary string:

    string temp;
    getline(cin, temp);
    courses[count].setCourseName(temp);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a C++ class that I have made with n number of pointers.
I am writing a program to find adapters, and have made a class called
I have a custom made class called Graph in which I use adjacency lists.
I made a class called SpecializationBean which has two private fields: private ArrayList<SelectItem> specializationItems=
I have a template class that I have made called hash . My template
I have a WPF application with the main Window class called MainWindow. Since I
I can not work this out. I have a class library called 'ABC.Service'. In
My situation is essentially this: I have a class called Foo which has dependencies
I have made a helper class called Navigation that gets used on every page
I have made a class Location which looks like this: package TruckingCompany; public class

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.