Why the size is coming to 1 it must come 3 as there are 3 arrays of 1 length?

list*l=new list[V];
l[0].push_back(1);
l[2].push_back(2);
l[1].push_back(3);
cout<size();

Hey @kingshuk441

list *l=new list[10]; //This line creates 10 list
l[0].push_back(0); //pushes 1 element in list 1
l[1].push_back(1); //pushes 1 element in list 2
l[2].push_back(2); //pushes 1 element in list 3
cout<<l->size()<<endl; //This return 1 because l is pointing to l[0]
cout<<l[1]->size();//This will also print 1

if we want the length of 10 so what syntax to write

Hey @kingshuk441
What exactly u want to do?
Please elaborate

what should we write to get total number of lists in l?in your example it is 10

Hey @kingshuk441
You have to use 10 or say u created n list n manually

for(int i=0;i<n;i++)cout<<l[i].size();

There is no direct method to see how many list u have created.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.