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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:33:44+00:00 2026-05-30T05:33:44+00:00

I am taking a C++ class and have a assignment which requires me to

  • 0

I am taking a C++ class and have a assignment which requires me to dynamically allocate memory for a struct. I don’t recall ever going over this in class and we only briefly touched on the new operator before going on to classes. Now I have to

“Dynamically allocate a student and then prompts the user for student’s first name, a last name, and A – number(ID number). ”

my struct is written like

struct Student
{
    string firstName, lastName, aNumber;
    double GPA;
};

I tried Student student1 = new Student; but that doesn’t work and I’m unsure as how I do this dynamically with a struct.

  • 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-30T05:33:45+00:00Added an answer on May 30, 2026 at 5:33 am

    Change you definition to

    struct Student 
    {
        string firstName, lastName, aNumber;
        double GPA;
    };
    

    Notice I have changed the placement of the struct keyword

    and you have to do Student* student1 = new Student instead.

    When you dynamically allocated memory for a struct you get a pointer to a struct.

    Once you are done with the Student you also have to remember to to release the dynamically allocated memory by doing a delete student1. You can use a std::shared_ptr to manage dynamically allocated memory automatically.

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

Sidebar

Related Questions

I'm taking a beginning Java class and an assignment requires that I write a
I am currently taking a class which is incorporating a topic I have not
I'm taking a class on JSP and I have an assignment... we have to
I have some C# class libraries, that were designed without taking into account things
In the data structures class that I am currently taking, we have been tasked
A class I am taking currently requires us to do all of our coding
I recently created a class which has a constructor taking 3 enumerations as arguments.
I am taking a SQL database class using Oracle. There's an assignment: Find the
I am taking a database class and have to draw a bunch of different
Note: This is for a SWING course I am taking. I have an assignment

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.