try catch
Hej hvorfor må jeg ikke lave et object i en try?Min kode:
#include <iostream>
#include "OVSocket.h"
int main(int argc, char *argv[])
{
try
{
OVSocket* socket = new OVSocket(0);
}
catch(OVSocketException &exc)
{
std::cerr << "Error in OVSocket: " << exc.What() << std::endl;
}
socket->OVCloseSocket(socket->OVGetSocketId());
return 0;
}
Fejlbesked:
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/main.d" -MT"src/main.d" -o"src/main.o" "../src/main.cpp"
../src/main.cpp: In function ‘int main(int, char**)’:
../src/main.cpp:9: warning: unused variable ‘socket’
../src/main.cpp:16: error: request for member ‘OVCloseSocket’ in ‘socket’, which is of non-class type ‘int ()(int, int, int)throw ()’
../src/main.cpp:16: error: request for member ‘OVGetSocketId’ in ‘socket’, which is of non-class type ‘int ()(int, int, int)throw ()’