Difficulties on atributting a array to another [closed]

You can’t copy an array with operator=. You can fix your problem using modern C++ #include <array> #include <cstddef> // #include <list> #include <string> // #include <vector> struct book{ std::string author; std::string title; }; std::array<book, 100> library; // or std::vector<book> library; // or std::list<book> library; void removebook(std::size_t idx) { for (std::size_t cont = idx; cont … Read more

push_back an object into vector

The second example has a memory leak. If what you want is just a “fill” function then setOfVertices.insert(setOfVertices.end(), 10, Vertex()); is good enough. However, if what you want instead is insert different Vertex objects then // Make sure only a single memory allocation takes place. setOfVertices.reserve(setOfVertices.size() + 10); for (int i = 0; i < … Read more

C++ : Unable to read from large txt file [closed]

Your problem is in the merge function: you exceed the local variable c. long c[30]; maybe there are more problems, that is the first I notice. EDIT Try this: find the differences… #include <map> #include <vector> #include <fstream> #include <iostream> #include <time.h> using namespace std; void merge(vector<long> &,long ,long , long ); void divide(vector<long> &arr,long … Read more

What is a vector of vector of point? [closed]

A vector is a templated class that can store anything that you ask it to store when you defined it. For example: vector<int> // vector that will store any number of integers vector<double> // vector of double precision floating points vector<string> // vector of strings vector<T> // vector of Ts, being understood that T is … Read more