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

The Archive Base Latest Questions

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

How can i access objects stored in a list. I don’t want to use

  • 0

How can i access objects stored in a list. I don’t want to use vectors or #include <list>. Any insight is appreciated. Thanks! Here are my class definitions:

class UnsortedType  // UnsortedType.h   
{
    private:                
        int length, currentPos;
        book info[MAX_ITEMS];


    public:             
        UnsortedType();
        bool IsFull()  const ;
        int  LengthIs()  const ;  // returns length of list
        void RetrieveItem(book& item, bool& found);
        void InsertItem(book item); // adds objects to the list
        void DeleteItem(book item); // deletes objects in the list
        void ResetList(); // resets list to default length -1
        void GetNextItem(book& item); // gets the next object in the list

};

Stored in this list are book objects. contained in these objects are the title, author, price, etc… My question is how do I access each object once they are stored in the list. I want to be able to compare attributes of the objects stored in the list. For example the prices of each book.

//main
#include <iostream>
#include "Book.h"
#include "textbook.h"
#include "Name.h"
#include "unsorted.h"

using namespace std;


int main()
{


    book b1("The Exception to the Rulers", "Amy", "Goodman", "Hyperion", 342, "1-4013-0131", 21.95,'N');
    book b2("Who moved my cheese", "Spencer", "Johnson", "Red Tree", 95, "0-399-14446-3", 19.99,  'H');
    book b3("Hellbound Hearts", "Neil", "Gaiman", "Dark Harvest", 326, "978-1-4391-4090-1", 16.00, 'F');

    UnsortedType L1; // creating a list "L1" 

    L1.InsertItem(b1); // populating the list with the first book
    L1.InsertItem(b2); // populating the list with the second book
    L1.InsertItem(b3); // populating the list with the third book


    return 0;
}

These are the functions that are in book.h

// book.h
enum RelationType
{
    LESS, EQUAL, GREATER
};

class book
{
private: 
    string title; 
    Name aurthor; 
    string publisher; 
    string ISBN; 
    int pages; 
    float price; 
    char code; 


public:
    RelationType ComparedTo(book) const;
    class negativeNumber{};
    void setTitle(string);
    void setAurthor(string f, string l);
    void setPublisher(string);
    void setISBN(string);
    void setPages(int);
    void setPrice(float);
    void setCode(char);
    string getTitle();
    Name getAurthor();
    string getPublisher();
    string getISBN();
    int getPages();
    float getPrice();
    char getCode();
    void PrintBook();
    book(); //default constructor
    book(string, string, string, string, int, string, float, char); //constructor with args
    ~book(); //Destructor
};
  • 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-14T09:39:16+00:00Added an answer on June 14, 2026 at 9:39 am
    Book& UnsortedType::operator[](const int i))
    {
      //check if array is in bounds
      return info[i];
    }
    

    this will allow you to access the book objects using the unsorted class L1[3];

    or in your case, heres an example that accesses each object and determines the lowest price of the books:

    double UnsortedType::FindLow()
    {
        double low = 9999;      //used to store lowest value
        for(int i = 0; i < length; i++) //loop through array
        {
            if(info[i].price < low) //if the price of this book is lower than the current lowest
                low = info[i].price;
                    //set low to new low
        }
        return low;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use shading on my OpenGL objects but can't seem to access
I would store objects in my std list on thread-safe way. I don't want
We can access the valueStack (and other objects of ActionContext ) using OGNL but
Possible Duplicate: C++ delete - It deletes my objects but I can still access
I'd like to restrict public access to some objects we have stored in S3,
Why I can access Session object in Page_Load method in instance of System.Web.UI.Page, but
Each request in my web app can get one data access object instance (of
How can I access raw body of request object given to me by expressjs?
I have an array that contains @sign in the object. I can't access that
If I have an object, with properties like name, phone_number, etc...how can I access

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.