|
From: David E. <tw...@us...> - 2003-10-23 12:05:46
|
Quoting Attila <sa...@fr...>:
> Hello,
>
> I got warning to the simple code below (exc.cpp) if I link
> the pthread library like
>
> gcc exc.cpp -lpthread -lstdc++
>
> (-D_REENTRANT omitted for simplicity). No problem if I don't
> link pthread like
>
> gcc exc.cpp -lstdc++
>
> I guess the libraries are linked dinamically because the
> executable is only 37K.
>
> #include <iostream>
>
> class Exception
> {
> public:
> int _type;
> Exception(int i) : _type(i) {}
> };
>
>
> int main()
> {
> try {
> throw new Exception(5);
If you use this...
throw Exception(5);
> } catch(Exception* e) {
..and this...
catch (Exception& e)
> std::cout << "gotcha! " << e->_type << std::endl;
> delete(e);
..then you won't have to delete the object.
> }
> return 0;
> }
>
--
\David
|