A
asdf
True or false ?
asdf said:True or false ?
asdf said:True or false ?
asdf said:True or false ?
asdf said:True or false ?
So function is not an object.
From the book C++ FAQs 2nd ed.
FAQ 5.06: What is an object? It depends on who you are. To a
programmer, an object is a region of storage with associated
semantics. To a designer, an object is any identifiable component in
the problem domain.
FAQ 5.08: A class can be thought of as a C=style function that can
maintain state between invocations in a thread-safe manner and can
also provide multiple services. If there wer exactly one instance of
a class, and all its member functions except for exactly one public:
member function were removed, the result would be a C-style function
(the object's data would correspond to static data that is local to
the function.)
Phlip said:asdf top-posted:
Read what I wrote. I think functions have all of those. Except you
can't create them with 'new', so their lifetime options are kind'a
limit.
However, the book Design Patterns sez to create the Flyweight Design
Pattern, you create a table of objects, each with no state.
Now if I felt like implementing that pattern using a table of
function pointers, then do I don't have a "reeeeeal" Flyweight
Design Pattern??
Or is the Standard's answer to the question "are functions objects?"
not always absolute and perfectly useful?
Daniel said:How does a function have state? More spicifically how does it have more
than one state?
By your own definition above (and Grady Booch's BTW) an "object" with no
state, isn't an object.
Of course, but are the stateless things used by the pattern objects?
I don't think anyone would argue that only objects can be useful.
Is the
definition useful? I think so, one needs to treat a state-full thing
differently than a stateless thing. An object different than a
non-object.
Daniel T. said:How does a function have state?
By your own definition above (and Grady Booch's BTW) an
"object" with no state, isn't an object.
This doesn't really sound like it belongs in comp.lang.c++ though.
How does a function have state? More spicifically how does it have more
than one state?
Phlip said:Objects have state, identity, lifespan, storage, and behavior. Which of
those do functions have? Can you point to a function?
So, if a function is not an object, what is the type-of-thing that a
pointer to a function points to?
I would say that a pointer-to-a-function is an example of a
pointer-to-an-object, and hence a function is an object.
Daniel said:From the book C++ FAQs 2nd ed.
FAQ 5.06: What is an object? It depends on who you are. To a
programmer, an object is a region of storage with associated
semantics. To a designer, an object is any identifiable component in
the problem domain.
FAQ 5.08: A class can be thought of as a C=style function that can
maintain state between invocations in a thread-safe manner and can
also provide multiple services.
This question seems to be about how the c++ community defines the
"object" concept.
I would say "false". Here's why.
The * symbol is used for dereferencing or defining a pointer to an
object.
However, the * symbol is also used to define a pointer to a function.
So, if a function is not an object, what is the type-of-thing that a
pointer to a function points to?
I would say that a pointer-to-a-function is an example of a
pointer-to-an-object, and hence a function is an object.
Paul Epstein
asdf said:True or false ?
How does a function have state? More spicifically how does it have more
than one state?
By your own definition above (and Grady Booch's BTW) an "object" with no
state, isn't an object.
This question seems to be about how the c++ community defines the
"object" concept.
I would say "false". Here's why.
The * symbol is used for dereferencing or defining a pointer to an
object.
However, the * symbol is also used to define a pointer to a function.
So, if a function is not an object, what is the type-of-thing that a
pointer to a function points to?
I would say that a pointer-to-a-function is an example of a
pointer-to-an-object, and hence a function is an object.
asdf said:True or false ?
Mike said:Compile and run the below program to get your answer:
#include <ciso646>
#include <iostream>
int main()
{
std::cout << true or false << '\n';
return 0;
}
-Mike
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.