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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:32:51+00:00 2026-05-26T04:32:51+00:00

while(getline(INPUT,textLine)) { Object* s = new Object(textLine); } How would I hold a reference

  • 0
while(getline(INPUT,textLine))
  {
    Object* s = new Object(textLine);
    }

How would I hold a reference to the Object of the previous textLine so that I could compare the two in some compare method

s.Compare(***); <– comparing the second iteration to the first

Note that *** is of type Object

  • 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-26T04:32:51+00:00Added an answer on May 26, 2026 at 4:32 am

    You want to keep track of the previous instance of Object?
    Put it in a variable (called t below), and use the variable when you need it.
    Remember to delete everything you allocate.

    Object* s;
    Object* t = NULL;
    
    while(getline(INPUT,textLine))
    {
        s = new Object(textLine);
        s->Compare(t);
    
        delete t; 
        t = s;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I use getline , I would input a bunch of strings or numbers,
As the question says, for some reason my program is not flushing the input
I want to add a new (fstream) function in a program that already uses
I have a program that sorts input lines lexicographically, and I've come to this
I'm looking at this program that reads input lines and then sorts them, from
void get_english_input() { string input = ; stringstream my_string(input); int ft; double in; while(true)
What does the istream::getline method return? I am asking because I have seen that
I’m trying to make something that will take lines of input from the user,
My program has a main thread that takes command input from a user. Separately,
While the C# spec does include a pre-processor and basic directives (#define, #if, etc),

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.