#include #include #include #include "Candy.h" using namespace std; int main() { // You can't actually do thisÉ cout << "How much candy?" << end; int pieces; cin >> pieces; Candy candyPile[pieces]; // Why not? The compiler needs to know how much memory to allocate at compile-time, // but 'pieces' isn't known until runtime. // Allocate the memory dynamically: Candy * candyPile = NULL; cin >> pieces; candyPile = new(nothrow) Candy[pieces]; if (candyPile == NULL) { // handle the error } // do stuff delete[] candyPile; candyPile = NULL; system("PAUSE"); return 0; }