I
idar.douglas.hillgaar
Hi - the following code compiled easily in VS.Net however using g++'s
there are several errors relating to template (I'm using a list()) -
using the latest ver. of g++
Code:
list <int> my_list2;
int counter;
const int size = 8;
int *seq = new int[size];
/* test values */
my_list2.push_back(1);
my_list2.push_back(2);
my_list2.push_back(3);
my_list2.push_back(1);
my_list2.push_back(3);
my_list2.push_back(2);
my_list2.push_back(2);
my_list2.push_back(3);
list <int>::iterator i;
if (my_list2.empty())
cout << "List is empty " << endl;
else
{
/* Adds integers to an array I need for 3rd lib. */
for( i = my_list2.begin(), count = 0; i != my_list2.end() && count <
size; i++, count ++)
{
seq[count] = *i;
}
}
/* printing out the values */
for (int i = 0; i < size; i++)
{
cout << " test: " << seq << endl;
}
Errors in g++:
readSequence.c: In function 'int main()':
readSequence.c:561: error: expected primary-expression before
'template'
readSequence.c:561: error: expected `;' before 'template'
readSequence.c:567: error: expected initializer before '*' token
readSequence.c:570: error: 'my_list2' was not declared in this
scope
readSequence.c:584: error: overloaded function with no contextual type
information
readSequence.c:584: error: parse error in template argument list
readSequence.c:584: error: expected `;' before ')' token
readSequence.c:586: error: 'seq' was not declared in this scope
readSequence.c:592: error: 'seq' was not declared in this scope
make: *** [readSequence.o] Error 1
there are several errors relating to template (I'm using a list()) -
using the latest ver. of g++
Code:
list <int> my_list2;
int counter;
const int size = 8;
int *seq = new int[size];
/* test values */
my_list2.push_back(1);
my_list2.push_back(2);
my_list2.push_back(3);
my_list2.push_back(1);
my_list2.push_back(3);
my_list2.push_back(2);
my_list2.push_back(2);
my_list2.push_back(3);
list <int>::iterator i;
if (my_list2.empty())
cout << "List is empty " << endl;
else
{
/* Adds integers to an array I need for 3rd lib. */
for( i = my_list2.begin(), count = 0; i != my_list2.end() && count <
size; i++, count ++)
{
seq[count] = *i;
}
}
/* printing out the values */
for (int i = 0; i < size; i++)
{
cout << " test: " << seq << endl;
}
Errors in g++:
readSequence.c: In function 'int main()':
readSequence.c:561: error: expected primary-expression before
'template'
readSequence.c:561: error: expected `;' before 'template'
readSequence.c:567: error: expected initializer before '*' token
readSequence.c:570: error: 'my_list2' was not declared in this
scope
readSequence.c:584: error: overloaded function with no contextual type
information
readSequence.c:584: error: parse error in template argument list
readSequence.c:584: error: expected `;' before ')' token
readSequence.c:586: error: 'seq' was not declared in this scope
readSequence.c:592: error: 'seq' was not declared in this scope
make: *** [readSequence.o] Error 1