title: constructor/copy/deconstructor not allowed in anonymous aggregate
body: <p>I am working on an operating system written in C++ to run on my own virtual machine, also written in C++. I have modified the original to allow for a time slice setup to run many programs at the same time. </p>
  
  <p>The issue I have is when compiling the os code. I am getting the following errors:</p>
  
  <pre><code>In file included from os.h:12,
                   from os.cpp:10:
  VirtualMachine.h:126: error: expected identifier before â;â token
  VirtualMachine.h:126: error: friend declaration does not name a class or function
  In file included from os.cpp:10:
  os.h:19: error: expected unqualified-id before â)â token
  os.h:33: error: expected identifier before â}â token
  os.h:33: error: expected unqualified-id before â}â token
  os.h:17: error: an anonymous struct cannot have function members
  os.h:23: error: member âAssembler &lt;anonymous class&gt;::asâ with constructor not allowed in anonymous aggregate
  os.h:23: error: member âAssembler &lt;anonymous class&gt;::asâ with destructor not allowed in     anonymous aggregate
  os.h:23: error: member âAssembler &lt;anonymous class&gt;::asâ with copy assignment operator     not allowed in anonymous aggregate
  os.h:24: error: member âVirtualMachine &lt;anonymous class&gt;::vmâ with constructor not     allowed in anonymous aggregate
  os.h:24: error: member âVirtualMachine &lt;anonymous class&gt;::vmâ with destructor not     allowed in anonymous aggregate
  os.h:24: error: member âVirtualMachine &lt;anonymous class&gt;::vmâ with copy assignment     operator not allowed in anonymous aggregate
  </code></pre>
  
  <p>I beleive this to be because of how I am using the virtual machine class in the os class.
  I have made the virtual machine a friend class of the os, but it still seems like I do not have access to the functions under the vm.</p>
  
  <p>OS.h</p>
  
  <pre><code>#ifndef OS
  #define OS
  
  #include "Assembler.h"
  #include "VirtualMachine.h"
  #include &lt;queue&gt;
  #include &lt;list&gt;
  #include &lt;iomanip&gt;
  
  class OS{
    public:
      OS();
      void run();
    private:
      void assembler_all();
      Assembler as;
      VirtualMachine vm;
      PCB * running;
      list&lt;PCB *&gt; pcb;
      list&lt;PCB *&gt; ended_jobs;
      queue&lt;PCB *&gt; waitq;
      queue&lt;PCB *&gt; readyq;
      queue&lt;PCB *&gt; runq;
  };
  
  #endif
  </code></pre>
  
  <p>Assembler.h</p>
  
  <pre><code>#ifndef ASSEMBLER
  #define ASSEMBLER
  
  #include &lt;vector&gt;
  #include &lt;string&gt;
  #include &lt;cstdlib&gt;  // for exit()
  #include &lt;iostream&gt; // for cout, ...
  #include &lt;fstream&gt;  // for fstream::open()
  #include &lt;sstream&gt;  // for istringstream
  #include &lt;bitset&gt;
  #include &lt;algorithm&gt;
  #include &lt;map&gt;
  
  using namespace std;
  
  class Assembler{
  private:
      static const int REG_MAX = 3;
      static const int MEM_SIZE = 256;
      string opcode;
          fstream assemblyProg; //reading the .s file
          string line, a_string, outname, inname;
          int rd, rs, constant, avalue, a_value, addr, mem_used, mem_current;
          vector&lt;int&gt; memory;
  
  public:
          void build(string filename);
          void reg_check(int val_reg);
          void val_check(int val);
          void addr_check(int val);
  };
  
  #endif
  </code></pre>
  
  <p>VirtualMachine.h</p>
  
  <pre><code>/*
  Filename: VirtualMachine.h
  Authors:
  Description: This file contains the 26 defined functions for our operating system
    as well as helper functions for out virtual machine. Souce code for the functions can     be
    found in the VirtualMachine.cpp file.
  */
  
  #ifndef VIRTUALMACHINE
  #define VIRTUALMACHINE
  
  #include &lt;list&gt;
  #include &lt;cstdio&gt;
  #include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt; 
  #include &lt;map&gt;
  #include &lt;stdio.h&gt;
  
  using namespace std;
  
  class format1 {
      public:
          unsigned UNUSED:6;
          unsigned RS:2;
          unsigned I:1;
          unsigned RD:2;
          unsigned OP:5;
  };
  
  class format2 {
      public:
          unsigned ADDR:8;
          unsigned I:1;
          unsigned RD:2;
          unsigned OP:5;
  };
  
  class format3 {
      public:
          int CONST:8;
          unsigned I:1;
          unsigned RD:2;
          unsigned OP:5;
  };
  
  union instruction {
          int i;
          format1 f1;
          format2 f2;
          format3 f3;
  };
  
  struct PCB{
      vector&lt;int&gt; r;
      int pc,sr,sp,base,limit, IO_clock;
      int CPU_time, largest_stack_size, ta_time, io_time, waiting_time; 
      string pName;
  
      ifstream pcb_in;//.in
      ofstream pcb_out;//.out
      fstream pcb_st;//.st
  };
  
  class VirtualMachine{
      public:
          VirtualMachine();
  
      void loads();           
      void store();           
      void adds();            
      void addc();            
      void subs();            
      void subc();            
      void ands();            
      void xors() ;       
      void compls();          
      void shl();         
      void shla();            
      void shr();         
      void shra();            
      void compr();           
      void getstat();         
      void putstat();     
      void jump();            
      void jumpl();           
      void jumpe();           
      void jumpg();           
      void call();            
      void returns();         
      void read();            
      void write();           
      void halt();            
      void noop();
  
          void setoverflow();     
      bool iscarry();
      void setcarry();
  //      void run(string);
  
      int  get_status() {return ((sr &amp; 0xE0) &gt;&gt; 5);}
      void run(PCB *);
      void savePCB(PCB *);
      void loadPCB(PCB *);
      void loadMem(list&lt;PCB *&gt; &amp;);    
  
      private:
          typedef void (VirtualMachine::*FP)();
          vector&lt;FP&gt; functions;        
          static const int REG_SIZE = 4;
          static const int MEM_SIZE = 256;
          static const int FMAP_SIZE = 26;
          vector&lt;int&gt; mem;
          vector&lt;int&gt; r;
          ifstream infile;
          ifstream infile2;        
          ofstream outfile;
      string wfile;
      string rfile;        
          int pc, limit, sr, clock, sp, base,mem_used, ir, time_slice;
          instruction lineObject;
          PCB * current;
  
          friend class OS;
  };
  
  #endif
  </code></pre>
  
  <p>What do I need to modify to allow the os to use the assembler and virtualmachine classes?</p>