Declare object without initializing
Can I declare an object variable without initializing it? This is mostly a scope problem:
Code:
int main () {
SomeObj eg; // but this is an initialization ...
try {
eg(blah blah); // so this is pointless
}
If I move the declaration into the try block, it is not in main's scope. I know I can do this:
Code:
int main () {
SomeObj *eg;
try {
eg = new SomeObj(blah blah);
}
But now I am using a pointer when I don't need to; also it's my understanding that if you use new, you then need to explicitly use delete.
Kind of a hassle, is there any way out?