Miranda functions and Initialization

K

Karl Heinz Buchegger

JKop said:
[snip]
There's just one thing that I want to figure out:

SomeClass object = SomeClass();

There has to be some sort of way of turning the following:

SomeClass object();

into an object definition. I've tried:

class SomeClass object();
struct SomeClass object();

But still they're a function declaration. That doesn't make sense to me.

That's because there are circumstances (don't remember which exactly) where
the compiler cannot differentaiate between a function declaration and an
object definition.
That's why there is the rule: If it lools like a function declaration, it
is a function declaration.

There is nothing you can do about it.
class SomeClass object();

object is a function which returns a class SomeClass object.
That's the way it is.
 
J

JKop

Karl Heinz Buchegger posted:
JKop said:
[snip]
There's just one thing that I want to figure out:

SomeClass object = SomeClass();

There has to be some sort of way of turning the following:

SomeClass object();

into an object definition. I've tried:

class SomeClass object();
struct SomeClass object();

But still they're a function declaration. That doesn't make sense to
me.

That's because there are circumstances (don't remember which exactly)
where the compiler cannot differentaiate between a function declaration
and an object definition.
That's why there is the rule: If it lools like a function declaration,
it is a function declaration.

There is nothing you can do about it.
class SomeClass object();

object is a function which returns a class SomeClass object.
That's the way it is.

I asked this question on comp.std.c++, but it seems the
asshole, opps I mean the moderator, didn't feel it was fit
for posting.


-JKop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top