Explore BrainMass

Data structures in C++

Please include the code.

Trace the following code, and display the resulting elements in the list.

int arr[] = {1, 2, 3, 4];
int arrSize = sizeof(arr)/sieof(int);
list<int> intList (arr, arr+arrSize);
list<int> :: iterator iter = intList.begin);
int i;

for (i=1; i <= arrSize; i++)
intList.insert(iter++, i);

Solution Preview

// iter1.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include <list>
#include ...

Solution Summary

A C++ code is traced and the resulting elements in the list are displayed.