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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:59:39+00:00 2026-05-26T10:59:39+00:00

I have a class apples class apples { private: double x; double y; double

  • 0

I have a class apples

class apples
{
  private:
      double x;
      double y;
      double z;
  public:
      //some methods
};

I want to store the pointer to apples objects in a vector.
I am doing this so that i create any object in any file & use any object in any file.
I used the following code to determine the max no of pointers i can store in that vector

int _tmain(int argc, _TCHAR* argv[])
{
vector<apples *> myvector;
cout<<"max :"<<myvector.max_size();
return 0;
}

it gave me:

1073741823

now, my question is that can i really store 1073741823 no of pointers in that vector or is this the memory limitation (i.e. 1073741823 bytes) of the vector?

so if there are 2 vectors

vector<int> A
& 
vector<double> B

can A have 1073741823 elements & B also have 1073741823 elements?
i am asking this to clarify that,
the max no of elements that a vector can store does not depend on the the type of entity (int or double) being stored?
(this has nothing to do with the current capacity of the vector!)
Also, what would be the size of a pointer to apples object (not asking the size of apples object!)?
Thank You.

  • 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-26T10:59:39+00:00Added an answer on May 26, 2026 at 10:59 am

    This is library limitation for storing elements in a vector.

    vector::max_size() :

    Returns the maximum number of elements that the vector container can
    hold.

    This is not the amount of storage space currently allocated to the
    vector (this can be obtained with member vector::capacity), but the
    maximum potential size the vector could reach due to system or library
    implementation limitations.

    So, you can not store more than it (and in practice maybe less than it due to system limitations)

    In other words even if you have best resource (memory, CPU, …) abilities and your elements have minimum size, you can not store more than max_size()

    And according to the comment on max_size() in the header file: Returns the size of the largest possible %vector.

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

Sidebar

Related Questions

I have a model like this defined... public class Product{ private long timestamp; //
Say I have some special class, WrappedDataTable , and I want to associate each
I have this custom type: public struct PasswordString { private string value; public PasswordString(string
Let's say we have a concrete class Apple . (Apple objects can be instantiated.)
I have class A: public class ClassA<T> Class B derives from A: public class
I have: class Car {..} class Other{ List<T> GetAll(){..} } I want to do:
I have this following interface : public interface FruitDetails { public String getFruitName(); }
How do i access some variables from another class? For example, i have 2
I have two classes defined in different h files and each class has some
I have a class with a large number of init... methods (UITableViewCell). My extension

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.