C++ code has segmentation fault. Need help CPP file: buffers #include vector.h #include #include //We do not want to include either stmt. We wouldn't ////be
C++ code has segmentation fault. Need help
CPP file: buffers #include "vector.h" #include Hpp file: vector.h 1 #ifndef VECTOR_H 2 #define VECTOR_H 3 #include
try_vector.cpp 1 #include vector.h 2 #include 3 #include 4 //We do not want to include either stmt. We wouldn t 5 ////be able to compare our vector template to the Standard 6 ////using namespace std; 7 ////using std::vector; 8 using std::cout; 9 using std::endl; 10 int main () { 11 12 13 14 15 16 17 18 19 20 21 23 24 25 26 27 28 29 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 } vector v; //Our vector class std::vector stdv; //Standard vector //Compare operation of our vector to std v.push_back (23); stdv.push_back (23); cout < < Our vector size: < < v.size() < < < endl; cout < < STL vector size: < < stdv.size() < < endl; for(int i=0; i capacity) { }else temp = new T[2*capacity]; ++s; temp = new T[++s]; for(int i=0; i
Step by Step Solution
3.44 Rating (151 Votes )
There are 3 Steps involved in it
Step: 1
The segment ation fault is caused by the fact that the code attem...See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started