dynamic two dimensional array

I have a class TrigramVector that can hold a TrigramVector for a file. What I am trying to do is in another class, called Language, is store all the Trigram Vectors for several files. I would like to have an array, where each index represents one language, and this can grow as I want to add more languages, like English or Spanish. Then for each language I want it to have an array that holds all the trigram vectors associated with that language.
Would this be done with a double pointer (**)?

Here is the section of my code, where I try to create this.

language_size = 5;
TrigramVector** = new TrigramVector*[language_size];
for(int i = 0; i < size; i++)
{
tv[i] = new tv[size];
}
"size" what this parameter represents in your code

tv[i] = new tv[size];
In the above line after new it will expects a type(TrigramVector) not parameter(tv);

Working Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
        long max_Langauge_size=5;
	long max_tvSize_InEachLang=12;

	TrigramVector** tv=new TrigramVector*[max_Langauge_size];

	for(int i=0;i<max_Langauge_size;i++)	
		tv[i]=new TrigramVector[max_tvSize_InEachLang];

	//Initializing TrigramVector
	for(int i=0;i<max_Langauge_size;i++)	
		for(int j=0;j<max_tvSize_InEachLang;j++)	
		{
			tv[i][j]=TrigramVector();//Constructing the new object and Assignment 
		}

thank you so much!
Topic archived. No new replies allowed.