473,769 Members | 7,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Object instance"

Can someone explain the "object instance" term that is used i many of C#
books? I have C++ background. In C++ instance and object meant the same. I
could say that I have object of some class or instance of some class.
There was no object instance used. How can I understand object instance?
(I don't mean framweork class named object)

--
Piotr (Peri, 3P) Perak
Nov 16 '05 #1
4 5521
hi piotr,
Can someone explain the "object instance" term that is used i many of C#
books? I have C++ background. In C++ instance and object meant the same.
I could say that I have object of some class or instance of some class.
There was no object instance used. How can I understand object instance?
(I don't mean framweork class named object)


go for "instances" and forget about the syntactic sugar.
some authors uses "object" as a synonyme for "class".

C++: MyClass *c = new MyClass();
C#: MyClass c = new MyClass();

both "c" are instances of classes.

however, the memory allocation of instances is different:

C++: MyClass c = MyClass(); // stack-allocated,
// can go out of scope
C++: MyClass *c = new MyClass(); // heap-allocated

C#: MyClass c = new MyClass(); // like heap-allocated, but
// garbage-collected

bye
rob
Nov 16 '05 #2
Dnia Sat, 21 Aug 2004 14:13:42 +0200, Robert Jordan <ro*****@gmx.ne t>
wrote:
hi piotr,

go for "instances" and forget about the syntactic sugar.
some authors uses "object" as a synonyme for "class". But is it correct? We have big arguement on polish c# list. One of us say
that object and instance is the same, and others say that class is object.
But how could class ba an object? Here's how I understand it. Class is
only idea for object. I have to use new to create object(instance ) of that
class.
C++: MyClass *c = new MyClass();
C#: MyClass c = new MyClass();

both "c" are instances of classes.

but in books I see c is "object instance". I don't get it. Maybe because
of not good enough knowing of english. For me it could be object instance
only if i did:
object o = new object();
like a d would be instance of Dog if I did:
Dog d = new Dog();

--
Piotr (Peri, 3P) Perak
Nov 16 '05 #3
Piotr Perak wrote:
Dnia Sat, 21 Aug 2004 14:13:42 +0200, Robert Jordan <ro*****@gmx.ne t>
wrote:
hi piotr,

go for "instances" and forget about the syntactic sugar.
some authors uses "object" as a synonyme for "class".


But is it correct? We have big arguement on polish c# list. One of us
say that object and instance is the same, and others say that class is
object. But how could class ba an object? Here's how I understand it.
Class is only idea for object. I have to use new to create
object(instance ) of that class.


do you want to speak to your compiler? he'll probably
not understand you, because he uses to understand
context-free grammars only! :-)

- classes are definitions
- objects are instances of classes
- "object instances" are redundant instances of classes.

bye
rob
Nov 16 '05 #4
Piotr,

It's just an effort to distance discussions from the common confusion
between "class" and "object". Many people have gotten sloppy in their use
of terminology and it clouds discussion with inaccuracies. Saying
"instance" instead of "object" emphasizes that you *really* mean the runtime
instance and not the design-time class. "Object" by itself is good I think,
but "object instance" is redunant and probably not helpful.

--Bob

"Piotr Perak" <pi********@WYT NIJTOpoczta.one t.pl> wrote in message
news:op******** ******@news.one t.pl...
Can someone explain the "object instance" term that is used i many of C#
books? I have C++ background. In C++ instance and object meant the same. I
could say that I have object of some class or instance of some class.
There was no object instance used. How can I understand object instance?
(I don't mean framweork class named object)

--
Piotr (Peri, 3P) Perak

Nov 16 '05 #5

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

Similar topics

0
2753
by: Bob Cannistraci | last post by:
A three-tier user authentication system was running without a problem for almost a year and now is suddenly dysfunctional. We don't know of any changes to any of the servers. It's quite maddening. The details: 1) We know the COM+ app is instanced on the COM+ server (Win 2000). The component graphic spins when CreateObject is called. 2) The proxy is installed on an IIS server (Win 2000) with delivers the interface, written in ASP, to the...
22
3351
by: Dr Duck | last post by:
GDay all, Something seems odd to me.... I wrote a simple C# function public void bind(ref object a, ref object b, bool atob) { if(atob) b = a; else
4
2496
by: Jian H. Li | last post by:
Hello, What's the essential differences between the two ways of "class::member" & "object.member"(or object_pointer->member)? class C{ public: void f() {} int i; };
3
19713
by: Steve Lutz | last post by:
Hi All, I have a Windows Service that runs well. The service hosts a remote object. The purpose of the object is so that I can "peak" into the service to see what it's doing. I wrote a small Windows Application that connects to the remote object and prints out status information. Everything works fine when I first start the service. However, after some period, when I attempt to connect to the remote object, I get "Requested Service not...
1
2832
by: Chris Magoun | last post by:
I suddenly received an unexpected error in my project. I have been working on this project for some time without this issue. Nothing has changed in the form that caused the exception. A little experimentation shows that I cannot run ANY .NET web project without getting this error: ---------------------------------------------------------------------------- ---- Object reference not set to an instance of an object.
18
28758
by: Microsoft | last post by:
When I try this in my code I alwas get an errormessage: "Object reference not set to an instance of an object" Dim g As System.Drawing.Graphics g.DrawString("Test", New Font("Arial", 12, FontStyle.Bold), Brushes.Black, 0, 0) Why is this? Marc
35
3232
by: Chris | last post by:
Hi, I tried to create a class which must change the propety 'visible' of a <linktag in the masterpage into 'false' when the user is logged. But i get the error: "Object reference not set to an instance of an object" for the line 'If mpg.FindControl("lkred").Visible = True Then'. I couldn't find sofar the solution. Any help would be appreciated ... Thanks
2
2006
by: Daniel Lipovetsky | last post by:
I would like for an object to "report" to a container object when a new instance is created or deleted. I could have a container object that is called when a new instance is created, as below. class AnyObject: pass class Container: links = def add(self,other):
4
2179
by: My Pet Programmer | last post by:
Ok guys, I'm really looking for someone to tell me how bad a hack this is, and if I'm close to where I should be with it. The basic situation is that I have a class which creates a basic calendar control, the only difference is I stole the navigation scheme from Vista (e.g., if you click on the year you zoom out to the months list, then out to the decade, and back in when you click a year, then a month). I ran into some trouble...
0
10216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5309
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
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
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.