When i run a black screen with cursor appears but nothing prints
THANKS
INTERFACE

//my_int_vector.h 

class my_int_vector
{
public:
	//destructor
	~my_int_vector();

	//copy constructor
	my_int_vector(const my_int_vector& b);

	//constructor that create an empty vector
	my_int_vector();

	/*constructor that create an vector with capacity specified 
	as a parameter but doesn't assign values to each element
	in the vector*/
	my_int_vector(unsigned int intial_Size);

	/*constructor that create a vector with capacity specified 
	as a parameter and assign all the elements the value 
	specified*/
	my_int_vector(unsigned int intial_Size, int assign);
	
	


	//returns total number of elements in an array
	int capacity();
	
	//returns number of elements in array that are filled
	int size();

	//adds an value at next position in vector
	void push_back(size_t user_number);

	//prints out the vector that contains the numbers
	void show_int_vector();

	//deletes the number from last element that stores a number
	void pop_back();

	//return value at the index specified by user
	int at(size_t arrayindex);
	
	//return value at index specified by user
	int operator[](size_t array_index);

private:

	//array to store numbers
	int* numbers;

	//total amount of elements that can be stored in array
	size_t capacit;

	//number of elements that are filled
	size_t siz;
};

IMPLEMENTATION

//Implementation of functions in my_int_vector.h

#include <iostream>
#include "my_int_vector.h"
using namespace std;

my_int_vector::~my_int_vector()
{
	delete[] numbers;
}

my_int_vector::my_int_vector(const my_int_vector& b)
{
	numbers=new int[capacit];
	for(size_t j=0; j<siz; j++)
	{
		numbers[j]=b.numbers[j];
	}
}

my_int_vector::my_int_vector()
{
	//cout<<"intial vector\n";
	siz=0;
	capacit=0;
	numbers=NULL;
}

my_int_vector::my_int_vector(unsigned int intial_Size)
{
	//cout<<"intial vector\n";
	siz=0;
	capacit=intial_Size;
	numbers=new int[capacit];
}

my_int_vector::my_int_vector(unsigned int intial_Size,int assign)
{
	//cout<<"intial vector\n";
	siz=0;
	capacit=intial_Size;
	numbers=new int[capacit];
	for(size_t b=0; b<capacit; b++)
	{
		numbers[b]=assign;
		siz++;
	}
}

int my_int_vector::at(size_t arrayindex)
{
	return numbers[arrayindex];
}

int my_int_vector::operator [](size_t arra)
{
	return numbers[arra];
}

void my_int_vector::push_back(size_t user_number)
{
	int* temp;
	//empty vector
	if(capacit==0)
	{
		//cout<<"increase size by one\n";
		capacit=capacit+1;
		numbers=new int[capacit];
		numbers[0]=user_number;
		siz++;
	}
	//last element contains a number
	else if(siz!=capacit)
	{
		//cout<<"store value at the next position in array\n";
		numbers[siz]=user_number;
		siz++;
	}
	//last element doesn't store any value
	else if(siz==capacit)
	{
		//cout<<"array out of space so double the capacity\n";
		temp=numbers;
		numbers=NULL;
		delete[] numbers;
		numbers=NULL;
		capacit=capacit*2;
		numbers=new int[capacit];
		for(size_t a=0; a<siz; a++)
		{
			numbers[a]=temp[a];
		}
		numbers[siz]=user_number;
		siz++;
	}
}

int my_int_vector::capacity()
{
	return capacit;
}


int my_int_vector::size()
{
	return siz;
}

void my_int_vector::pop_back()
{
	//cout<<"remove the last position value in vector\n";
	siz--;
}
	
void my_int_vector::show_int_vector()
{
	for(size_t a=0; a<siz; a++)
	{
		cout<<a<<":";
		cout<<numbers[a]<<"\n";
	}
}

MAIN

#include "My_Int_Vector.h"
#include <iostream>

using namespace std;

int main()
{
	//Test 1
	my_int_vector c;
	c.push_back(10);
	my_int_vector a(c);
	a.show_int_vector();
	return 0;
}

Here's the function:

my_int_vector::my_int_vector(const my_int_vector& b)
{
	numbers=new int[b.capacit];
	for(size_t j=0; j<b.siz; j++)
	{
		numbers[j]=b.numbers[j];
	}
}

Edited 7 Years Ago by lotrsimp12345: n/a

You forget to assign siz member.

my_int_vector::my_int_vector(const my_int_vector& b)
{
	numbers=new int[b.capacit];
                siz=b.siz;
	for(size_t j=0; j<b.siz; j++)
	{
		numbers[j]=b.numbers[j];
	}
}

so why do i have to assign the size member since i already have b.siz ?

Edited 7 Years Ago by lotrsimp12345: n/a

Your copy constructor is not complete.

my_int_vector::my_int_vector(const my_int_vector& b)
{
	numbers=new int[capacit];
	for(size_t j=0; j<siz; j++)
	{
		numbers[j]=b.numbers[j];
	}
}

What happens is numbers is already pointing at another memory location.
What happens if the copy constructor is copying its self?

This question has already been answered. Start a new discussion instead.