Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. //I've got an example in a C++ book that is given without context.
  2. //I'm trying to put it in different ways, but Visual Studio 2015 compiler gives "ugh" in any of my attempts
  3. //Is it possible there is a mistake somewhere?
  4. //
  5. // This is the example as is:
  6. //struct complex{
  7. //  float real, im;
  8. //} compl [2][3] = {          
  9. //  { { 1,1 },{ 1,1 },{ 1,1 } },
  10. //  { { 2,2 },{ 2,2 },{ 2,2 } }
  11. //};
  12.  
  13. // this is what I am doing:
  14. #include <iostream>
  15. #include <string>
  16. using namespace std;
  17.  
  18. struct complex{
  19.     float real, im;
  20. } compl [2][3] = {           //error: expected an ;
  21.     { {1,1}, {1,1}, {1,1} },
  22.     { {2,2}, {2,2}, {2,2} }
  23. };
  24.  
  25.  
  26. int main() {
  27.        
  28.     struct complex {
  29.         float real, im;
  30.     } compl [2][3] = {           //error: expected an ;  && error: expected an identifier
  31.         { { 1,1 },{ 1,1 },{ 1,1 } },
  32.         { { 2,2 },{ 2,2 },{ 2,2 } }
  33.     };
  34.    
  35.     cin.ignore();
  36.    
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement