473,673 Members | 2,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Instance creation

Hello,
I get the same o/p for the 2 pieces of code below:
Base *b = new Base ;
b->test() ;
delete b ;

vs just saying:
(new Base)->test() ;

In the second case, how is the object created and what instance of the
object do we have to "delete" at the end of the program. It's a very
fundamental thing which I seem to be getting confused at. Inputs are
welcome.

Thanks

Aug 20 '05 #1
2 1472
da*********@yah oo.com wrote:
Hello,
I get the same o/p for the 2 pieces of code below:
Base *b = new Base ;
b->test() ;
delete b ;

vs just saying:
(new Base)->test() ;
What is an "o/p"?
In the second case, how is the object created
Just the same as in the first case. Dynamically with new.
and what instance of the object do we have to "delete" at the end of the
program.


Well, you didn't store the pointer to it, so unless Base's constructor or
the test() member function stores it somewhere, that pointer is lost and
you cannot delete the object.

Aug 20 '05 #2
o/p as in output.
Well, you didn't store the pointer to it, so unless Base's
constructor or the test() member function stores it
somewhere, that pointer is lost and you cannot delete the
object.


hmm.. Thanks for the suggestion, I will ponder over it :)

Aug 20 '05 #3

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

Similar topics

14
3323
by: Sridhar R | last post by:
Consider the code below, class Base(object): pass class Derived(object): def __new__(cls, *args, **kwds): # some_factory returns an instance of Base # and I have to derive from this instance!
6
7742
by: Andre Meyer | last post by:
Hi all I have been searching everywhere for this, but have not found a solution, yet. What I need is to create an object that is an instance of a class (NOT a class instance!) of which I only know the name as a string. This what I tried: class A:
18
5653
by: Steve Barnett | last post by:
I want to ensure that there is only ever one instance of my app running on a single PC at any time. I understand that I can achieve this by using a mutex and, if I can't take ownership of the mutex, I know there is another instance of my program running. Problem is, how do I get the "new" instance to communicate with the "old" instance? The new one will have been started with a command line parameter that I want to pass to the old...
1
3192
by: Anurag | last post by:
Hello Folks, Here's wishing you MERRY CHRISTMAS and Festive seasons's greeting!! Now this has been bugging me for quite a while and I seek your help in setting my mind to peace. As part of DB2 Instance creation on Unix, I issue this command (from standard script): _________________________________________________________ "db2iexec db2inst1 . sqllib/db2profile" _________________________________________________________
5
1468
by: Russell Warren | last post by:
I just ran across a case which seems like an odd exception to either what I understand as the "normal" variable lookup scheme in an instance/object heirarchy, or to the rules regarding variable usage before creation. Check this out: >>> class foo(object): .... I = 1 .... def __init__(self): .... print self.__dict__ .... self.I += 1
8
2080
by: al pacino | last post by:
hi, i want to know how does c++ compiler prohibits the creation of instance of an abstract class? i think it must be checking on the vtable entry if there is an entry with zero(indicting abstract class) but exactly how it is done. thanks in advance
5
3168
by: JH | last post by:
Hi I found that a type/class are both a subclass and a instance of base type "object". It conflicts to my understanding that: 1.) a type/class object is created from class statement 2.) a instance is created by "calling" a class object.
9
1218
by: glomde | last post by:
Hi I wonder if you can set what subclass a class should have at instance creation. The problem is that I have something like: class CoreLang(): def AssignVar(self, var, value): pass class Lang1(CoreLang):
1
6733
by: mitrofun63 | last post by:
Hi, All I have trouble with db2 instance creation (DB2 9.1.2 on AIX 5.3) When i run command for instance creation : ../db2icrt -a SERVER -p 50000 -s ese -u db2fenc1 db2inst1 a reciveve error in generated log file db2icrt.log.118872 :
0
2646
tlhintoq
by: tlhintoq | last post by:
My project involves reading magstripe cards, capturing an ID number, then spinning off to do some other things including taking a photograph. 99% of this is done and good. All early phases of work went well... Until the final assembly and "beefing up" of the project. The magcard reader is made by Magtek. They provide an ActiveX component as the sole means of communication with this RS-232 serial port device. It works great as long as it...
0
8509
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8429
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8704
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...
0
7487
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6266
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...
1
5729
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
4451
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2853
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
3
1852
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.