08-07-2007
Quote:
Originally Posted by
amitpansuria
helo i m new in c++ on linux
can u tell me with an simple example that how do you handle constructor and destructor that fail?
I was under the impression that the only things you should put in constructors/destructors were things that would not fail (or else you deal with the exceptions inside the constructor/destructor).
8 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi guys I am new to these forums but since I am taking a class at college I would appreciate any help that is possible for this program. My instructor said that when its complete the program should be able to store all 3 fields instead of just 1.
public class Greeter2Test
{
public static... (4 Replies)
Discussion started by: woot4moo
4 Replies
2. Programming
helo i read many books but i cant find the proper answer that why
constructor cannot be virtual
can u explain me in simple term that why constructor cannot be virtual
Regards,
Amit (2 Replies)
Discussion started by: amitpansuria
2 Replies
3. Shell Programming and Scripting
Hi,
Is it possible to call the constructur of a java class in a shell script?
I know you can call static methods, but can you also call the constructor?
tnx. (1 Reply)
Discussion started by: thebladerunner
1 Replies
4. Programming
Hi All,
I have made the simple following program :-
#include <string>
#include <iostream>
using namespace std;
class A{
private: int val;
public :
A(){cout<<"In A()"<<endl;}
A (const A& aa)
{
cout<<"In copy c'tor"<<endl;
}
};
A f(... (1 Reply)
Discussion started by: shubhranshu
1 Replies
5. Programming
I have the following code
class Param{
public:
Param(int aa, int bb){
a=aa;
b=bb;
}
int a,b;
};
void function(Param);
int main(){
function(2,3);
return 0;
} (6 Replies)
Discussion started by: santiagorf
6 Replies
6. Programming
Hi,
If I run the following program
class A {
public:
A() { cout << "default" << endl; }
A(const A&) { cout << "copy" << endl; }
};
A tmp;
A fun() {
return tmp;
}
A test() {
A tmp;
cout << &tmp << endl;
return tmp;
} (1 Reply)
Discussion started by: royalibrahim
1 Replies
7. UNIX for Dummies Questions & Answers
This question might be silly but its confusing me a bit:
What is the difference between handle to the thread HANDLE and thread identifier pthread_t?
---------- Post updated at 01:52 PM ---------- Previous update was at 01:48 PM ----------
Sorry I saw details and HANDLE is in windows and... (0 Replies)
Discussion started by: rupeshkp728
0 Replies
8. Programming
I am learning about C++ and today am reading concepts for Constructor but it seems a bit difficult to grab it fully. Please anyone explain in simple words about Constructor? (1 Reply)
Discussion started by: ggiwebsinfo
1 Replies
local(n) [incr Tcl] local(n)
__________________________________________________________________________________________________________________________________________________
NAME
local - create an object local to a procedure
SYNOPSIS
itcl::local className objName ?arg arg ...?
_________________________________________________________________
DESCRIPTION
The local command creates an [incr Tcl] object that is local to the current call frame. When the call frame goes away, the object is auto-
matically deleted. This command is useful for creating objects that are local to a procedure.
As a side effect, this command creates a variable named "itcl-local-xxx", where xxx is the name of the object that is created. This vari-
able detects when the call frame is destroyed and automatically deletes the associated object.
EXAMPLE
In the following example, a simple "counter" object is used within the procedure "test". The counter is created as a local object, so it
is automatically deleted each time the procedure exits. The puts statements included in the constructor/destructor show the object coming
and going as the procedure is called.
itcl::class counter {
private variable count 0
constructor {} {
puts "created: $this"
}
destructor {
puts "deleted: $this"
}
method bump {{by 1}} {
incr count $by
}
method get {} {
return $count
}
}
proc test {val} {
local counter x
for {set i 0} {$i < $val} {incr i} {
x bump
}
return [x get]
}
set result [test 5]
puts "test: $result"
set result [test 10]
puts "test: $result"
puts "objects: [itcl::find objects *]"
KEYWORDS
class, object, procedure
itcl local(n)