bravo1382 0 Newbie Poster

Hello all,
I am fairly new to c++ and I am completely lost right now. I am suppose to create two dynamic arrays that prompt the user to enter how big the arrays should be and it also asks the user to enter the numbers they want to store in the array. Once this is done I must combine the two dynamic arrays into one dynamic array that holds all the elements from the combined arrays. Can anyone help? I don't know if to pass the objects into a function and then combine? If so, how is the syntax for that. Thanks any help is greatly appreciated.

#include <iostream>
#include <cassert>
using namespace std;

class dynArr
{
private:
	int capacity;
	int *myArray;
public:
	dynArr(int maxSize = 1500);
	dynArr(const dynArr & origList,int num,int num2);
	~dynArr();
	void insert();
	void show();
};

dynArr::~dynArr()
{
	delete [] myArray;
}

dynArr::dynArr(int maxSize)
{
	capacity = maxSize;
	myArray = new (nothrow) int[capacity];

	if(myArray == 0) 
	{
		cerr<< "Error: space could not be allocated" << endl;
		exit(1);
	}
}

void dynArr::insert()
{
	for(int count = 0;count <capacity; count++)
	{
		cout << "enter the " << count + 1 << "value for your array: " << endl;
		cin >> myArray[count];
	}
}
void dynArr::show()
{
	for(int count = 0;count < capacity; count++)
	{
		cout<< myArray[count] << " ";
	}
}
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;


int main()
{
	int num, num2;

	cout << "enter the size of the first array: " << endl;
	cin >> num;
	
	dynArr dArr1(num);

	dArr1.insert();

	cout << "enter the size of the second array: " << endl;
	cin >> num2;
	dynArr dArr2(num2);
	
	dArr2.insert();

	dArr1.show();
	cout << endl;
	dArr2.show();

	system("pause");
	return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.