Please help me to find error in this program .I am trying to add data to a dynamic array .

#include<iostream.h>
#include<conio.h>
#include<string.h>

class data
{
	private:

		char(* dynamicarray)[20];
		int size1,i;

	public:

		data(char(*tmp)[20],int Size)
		{
			dynamicarray = new char(Size([20]);
			dynamicarray = tmp;
			size1 = Size;
		}
		get()
		{
			for(i=0;i<size1;i++)
			{
				cout<<dynamicarray[i];
			}
		}
	};


	main()


	{
		 char array1[5][20] ={"tom","dick"};
		 int Size1 =5;
		 data obj;
		 obj.data(array1,Size1);
		 data g;
		 obj.get();
		 return 0;


	}

Honestly speaking it looks like an absolutely senseless text written in unknown language.
May be better you present your assignment?..

dynamicarray = new char(Size([20]);
dynamicarray = tmp;

There's a classic error. Why is it so?

your code :

dynamicarray = new char(Size([20]);

my code :

...
dynamicarray = new char(Size([20])); // <-- ???
//--or
dynamicarray = new char(Size(20));
//--or
dynamicarray = new char[20];
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.