D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

[LUG] A programming problem



Are there any Charlie Double Plus programmers who could explain this
little conundrum to me ?

When I compile the following programme

===

int main() {
   int * a = new int;
   int b;
   switch (b) {
      case 0 :
         int * c = new int;
         // int * c;                  Compiles sucessfully
         // c = new int;              if I do it this way
         break;
      case 1 :
         int * d = new int;
         break;
   }
   return 0;
}
===
- I get the following error :
===

test.cpp: In function `int main ()':
test.cpp:10: jump to case label
test.cpp:6:   crosses initialization of `int *c'

===

Am relatively new to the wonderful world of C++, so is probably something
elementary I am getting wrong.


As an quick aside - and note that I am only adding this to an eMail that I
was going to send anyway, so excuse myself from blacking the kettle - I
would like to say that I hope Ray (Smith) is not put off the LUG by the
rudeness of one or two subscribers. I certainly do not mind the occasional
eMail that is possibly misplaced but certainly well intentioned, but I do
not like to read the public whinings of those who could have easily just
made a gentle suggestion in a private eMail to Ray. Any complaints about
my view, please complain to me, not to the list, unless you really want to
prove my point for me.


Regards to all, Tom.



--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.


Lynx friendly