jamesjuett / lobster

Interactive Program Visualization Tools
8 stars 3 forks source link

Nested Aggregate Initialization #348

Open jamesjuett opened 1 year ago

jamesjuett commented 1 year ago
#include <iostream>
#include <string>
#include <vector>
using namespace std;

// Task 1: Define a struct called "Sandwich" with the members listed below.
//         Use the names given and choose an appropriate type for each.
//  "name"    A name, e.g. "Reuben", "Tofu Bánh mì", "Chicken Shawarma"
//  "is_veg"  A true/false value indicating whether the sandwich is vegetarian
//  "price"   The cost to buy the sandiwch, e.g. 7.99

struct Sandwich {
  string name;
  bool is_veg;
  double price;
  vector<int> v;
};

int main() {
  Sandwich s = {"test", false, 2.5, {1, 2, 3}};
  cout << s.name << endl;
  cout << s.is_veg << endl;
  cout << s.price << endl;
}

I think this is a parsing issue. Might just work once the grammar is adjusted to accommodate this.