473,545 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C objects

What is a C object ?

If i have some function "func()" in my C program, then
can i say that "func()" is a C object ?
or if i have some function pointer (ptr) which contains the address
of function "func()", can i say that ptr is pointing to some C object ?

Is a C object always associated with some "data" ?

thanx in advance for any help .....
Nov 14 '05 #1
115 4814
"junky_fell ow" <ju**********@y ahoo.co.in> wrote in message
news:8c******** *************** ***@posting.goo gle.com...
What is a C object ?


C has objects? When did that happen?!

Boy I have GOT to get one of these new "standards" gizmos...

--
Mabden
Nov 14 '05 #2
junky_fellow wrote:

What is a C object ?
N869
3.15
[#1] object
region of data storage in the execution environment, the
contents of which can represent values
If i have some function "func()" in my C program, then
can i say that "func()" is a C object ?
No.
or if i have some function pointer (ptr) which contains the address
of function "func()",
can i say that ptr is pointing to some C object ?
No.
Is a C object always associated with some "data" ?


Normally, yes, though I suppose you could malloc some memory and
free it immediately if you wanted to, without involving any data.

Examples of objects are:
local variables,
external variables,
the memory returned by malloc and friends,
and string literals in a pointer context, refer to objects

When accessed by an identifier of object type,
objects can contain values.
The sizes of various types defined by the language,
are implementation defined.

Functions are not objects. The standard doesn't say very much
about how functions are represented in memory.
The address, is the only addressable byte of a function.
You don't know anything about how the rest of the function
resides in memory.
The sizeof operation is not defined for functions.

--
pete
Nov 14 '05 #3
"Mabden" <mabden@sbc_glo bal.net> writes:
"junky_fell ow" <ju**********@y ahoo.co.in> wrote in message
news:8c******** *************** ***@posting.goo gle.com...
What is a C object ?


C has objects? When did that happen?!

Boy I have GOT to get one of these new "standards" gizmos...


Yes, C has objects. (They have nothing to do with what's commonly
called "object-oriented programming".)

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #4
junky_fellow wrote on 07/08/04 :
What is a C object ?
A variable.
If i have some function "func()" in my C program, then
can i say that "func()" is a C object ?
Nope.
or if i have some function pointer (ptr) which contains the address
of function "func()", can i say that ptr is pointing to some C object ?
Nope.
Is a C object always associated with some "data" ?


It *is* data.

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

"C is a sharp tool"

Nov 14 '05 #5
On Sat, 07 Aug 2004 10:05:46 GMT, Keith Thompson <ks***@mib.or g> wrote
in comp.lang.c:
"Mabden" <mabden@sbc_glo bal.net> writes:
"junky_fell ow" <ju**********@y ahoo.co.in> wrote in message
news:8c******** *************** ***@posting.goo gle.com...
What is a C object ?


C has objects? When did that happen?!

Boy I have GOT to get one of these new "standards" gizmos...


Yes, C has objects. (They have nothing to do with what's commonly
called "object-oriented programming".)


....and interestingly enough, if slightly OT, is the fact that the
definition of the term 'object' in C++ is the same as it is in C.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #6
On Sat, 07 Aug 2004 15:49:48 +0200, Emmanuel Delahaye
<em***@YOURBRAn oos.fr> wrote in comp.lang.c:
junky_fellow wrote on 07/08/04 :
What is a C object ?


A variable.


const int x = 10;

'x' is an object.

char *hello_world = "hello world";

Both the pointer and the string literal it points to are objects.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #7
ra*@zedat.fu-berlin.de (Stefan Ram) writes:
Emmanuel Delahaye <em***@YOURBRAn oos.fr> writes:
What is a C object ?

A variable.


An object is a region of data storage in the execution
environment (3.14).

A variable is an identifier for an object introduced by a
declaration.

An object does not need to have a variable.


The C standard does not define the term "variable". It uses it
informally, but only a few times.

There was a long and futile discussion here recently about whether
something like *ptr is a variable (there is no definitive answer).

<OT>The C++ standard does define the term "variable"; I don't remember
what the definition is.</OT>

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #8
junky_fellow wrote:
What is a C object?
A *data* object.
If I have some function "func()" in my C program,
then can I say that "func()" is a C object?
Yes.
Or, if I have some function pointer (ptr)
which contains the address of function "func()",
can I say that ptr is pointing to some C object?
Yes.
Is a C object always associated with some "data"?


Yes. Objects are *data* objects
in the context of any computer programming language.

Be aware that the term *object* also has a special meaning
in the context of ISO C standards documents
which corresponds roughly to mutable storage, lvalues or variables.
Nov 14 '05 #9
pete wrote:
junky_fellow wrote:
Is a C object always associated with some "data" ?

Normally, yes, though I suppose you could malloc some memory and
free it immediately if you wanted to, without involving any data.


No.

malloc() doesn't create objects.
It returns a pointer of type void*.
A data object must be initialized to a valid value
of an object of that type before you can call it an object --
it must be constructed.
Nov 14 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8240
by: dasod | last post by:
I would like to know if my method to remove list objects is correct in this small test program. It seems to me that there might be a simplier way, but I'm afraid I don't know enough about list iterators and how they are behaving in situations like this. #include <iostream> #include <list> class Test; typedef std::list< Test* > Tlist;
9
1871
by: Aguilar, James | last post by:
Hey guys. A new question: I want to use an STL libarary to hold a bunch of objects I create. Actually, it will hold references to the objects, but that's beside the point, for the most part. Here's the question: I want to be able to change the references (including deleting them). Is there any way to do that besides using pointers rather...
6
2557
by: Alfonso Morra | last post by:
I have written the following code, to test the concept of storing objects in a vector. I encounter two run time errors: 1). myClass gets destructed when pushed onto the vector 2). Prog throws a "SEGV" when run (presumably - attempt to delete deleted memory. Please take a look and see if you can notice any mistakes I'm making. Basically,...
3
3015
by: ytrewq | last post by:
Should dynamic ("expando") properties be restricted to native and user-defined objects? Or should host objects - such as references to the browser or a plug-in or to the document and its elements - also allow them? Adding (and removing) object properties dynamically is an acceptable and common practice in JavaScript, and greatly adds to the...
8
1847
by: Lüpher Cypher | last post by:
Hi, Suppose we have a hierarchical class structure that looks something like this: Object | +-- Main | +-- Object1
161
7741
by: KraftDiner | last post by:
I was under the assumption that everything in python was a refrence... so if I code this: lst = for i in lst: if i==2: i = 4 print lst I though the contents of lst would be modified.. (After reading that
7
8206
by: Jo | last post by:
Hi, How can i differentiate between static and dynamic allocated objects? For example: void SomeFunction1() { CObject *objectp = new CObject; CObject object;
21
2192
by: George Exarchakos | last post by:
Hi everyone, I'd like your help... Can we have a std::list<BASEwhere BASE be the base class of a class hierarchy? I want to add to this list objects that are inherited from BASE class but not necessarily the same... class base { int x;
27
2530
by: SasQ | last post by:
Hello. I wonder if literal constants are objects, or they're only "naked" values not contained in any object? I have read that literal constants may not to be allocated by the compiler. If the Standard is saying that "object is a region of storage", I deduce from that that literal constants aren't objects because they may not be alocated...
14
5984
by: Jess | last post by:
Hello, I learned that there are five kinds of static objects, namely 1. global objects 2. object defined in namespace scope 3. object declared static instead classes 4. objects declared static inside functions (i.e. local static objects) 5. objects declared at file scope.
0
7487
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7934
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5349
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3476
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
731
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.