473,509 Members | 2,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

object initialized to zero(not a pure virtual function)

22 New Member
hi
i saw a program which inside its class initializes another class object to zero.
also if i initialize to some other number other than zero ,an error occurs.

Expand|Select|Wrap|Line Numbers
  1. Circle* cp = 0;
this is not related with pure virtual function since it is an object not a function.

can some one could explain what it is.
Dec 26 '07 #1
5 1630
scruggsy
147 New Member
hi
i saw a program which inside its class initializes another class object to zero.
also if i initialize to some other number other than zero ,an error occurs.

Expand|Select|Wrap|Line Numbers
  1. Circle* cp = 0;
this is not related with pure virtual function since it is an object not a function.

can some one could explain what it is.
A pointer with a value of zero is called a null pointer; it means the pointer points to nothing.
In C++ it's more common to use Circle* cp = NULL; to make the intention more clear. Either way, pointers should always be initialized to NULL (or 0); otherwise they may point to garbage and produce difficult-to-find bugs.
Dec 26 '07 #2
babu198649
22 New Member
thanks....................
Dec 26 '07 #3
babu198649
22 New Member
does pointing to 0(NULL) will not point to data in 0th location
Dec 26 '07 #4
weaknessforcats
9,208 Recognized Expert Moderator Expert
Circle* cp = NULL;
This is C. There is no NULL in C++. Use 0.
Dec 26 '07 #5
scruggsy
147 New Member
This is C. There is no NULL in C++. Use 0.
Really? My mistake. Thanks.
In any case, babu, if you try to dereference a pointer with a value of 0, most operating systems generate an exception. If you dereference an uninitialized pointer, on the other hand, the OS can't tell that you've made a mistake, which makes the error much more difficult for you to track down.
Dec 26 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2136
by: satish | last post by:
Hello all, I have a python module generated by SWIG. When I try to import the moduleI get the following error : >>> import overturec Traceback (most recent call last): File "<stdin>", line...
6
1592
by: WindAndWaves | last post by:
Hi Everyone, Here is another question: I run a database in Access RT in a Virtual PC environment. Every now and then I get an error: "Object Not set", which then freezes everything. Not...
2
3996
by: Jan Szymczuk | last post by:
I have created an MSAccess 2000 Database that has a couple of OLE Object fields that hold photos and Map locations (which I upload in JPG format), On the form I have the Photo and Map location...
1
2580
by: Roman S. Golubin | last post by:
Hi, I install sqlxml 3.0 SP2. Then I create vDir "service" (with windows auth) and configure the SOAP virtual name "vname". Then I generate a proxy with wsdl.exe tool from...
2
1049
by: juli jul | last post by:
Hello, I am doing this initialization : this.oXmlDoc=new XmlDocument(); in InitializeComponent() function. And once in a while because of some reason I can't detect this statement is being...
1
2122
by: aaa | last post by:
I am using a third party provider for Travel related web services. These services are not very well documented and I am having to wing my way thru nearly every one. Some I can pull data from...
0
1927
by: Jagdish | last post by:
Hello, Every body I have recently joined this group and I want to know how to pass Array of string to a Com object function.. Actually I want to pass String array from VB6 to Com Interface...
0
910
by: kempshall | last post by:
I have a web application that I just migrated from ASP.NET 1.1 to 2.0. My problem is that when I execute the application, the Global constructor and the Global.Application_BeginRequest methods...
8
3236
by: webgenius | last post by:
Whenever I click the SUBMIT button in my HTML page, I get the "Object not found!" error. It was working fine yesterday. This error started to occur after I installed Codelobster and made some changes...
0
7137
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...
0
7347
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,...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7506
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...
0
3218
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...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
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 ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
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...

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.