Click here to Skip to main content
15,892,697 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralDirectShow - Capturin video to an avi file Pin
defused17-Oct-04 19:40
defused17-Oct-04 19:40 
GeneralA prolem with Static text ! Pin
King of Merit17-Oct-04 17:59
King of Merit17-Oct-04 17:59 
GeneralRe: A prolem with Static text ! Pin
Ryan Binns17-Oct-04 18:17
Ryan Binns17-Oct-04 18:17 
GeneralRe: A prolem with Static text ! Pin
Sujan Christo17-Oct-04 18:21
Sujan Christo17-Oct-04 18:21 
GeneralManaging Header-Files Pin
Anonymous17-Oct-04 14:21
Anonymous17-Oct-04 14:21 
GeneralRe: Managing Header-Files Pin
toxcct17-Oct-04 21:14
toxcct17-Oct-04 21:14 
QuestionWhat is wrong with my code!! trying to call from one form to the other and back Pin
V5Dave17-Oct-04 11:54
V5Dave17-Oct-04 11:54 
QuestionDestructor not getting rid of the instance? Pin
Kieroshark17-Oct-04 10:03
Kieroshark17-Oct-04 10:03 
For some reason, when I call the destructor of an instance, it doesn't actually destroy the instance? Confused | :confused: Sigh | :sigh:

Is there something up with my compiler (Microsoft Visual C++ 6.0) or am I misunderstanding how destructors work and/or what they do?

Here is an example of what I am talking about:


class A <br />
{<br />
	public:	<br />
		A(): itsVariable(3) {cout << "A's constructor was called.\n";}<br />
		~A() {cout << "A's destructor was called.\n";}<br />
<br />
		int GetVar() {return itsVariable;}<br />
		void PrintSomething() {cout << "A's PrintSomething function was called.\n";}<br />
<br />
	private:<br />
		int itsVariable;<br />
};<br />
<br />
int main()<br />
{<br />
	A instance;<br />
	instance.~A();<br />
<br />
	instance.PrintSomething();<br />
	cout << "instance.GetVar() returns: " << instance.GetVar() << ".\n";<br />
<br />
	cout << "Main has now ended, therefore instance is out of scope.\n";<br />
	return 0;<br />
}


The program produces this output:

A's constructor was called.
A's destructor was called.
A's PrintSomething function was called
instance.GetVar() returns: 3.
Main has now ended, therefore instance is out of scope.
A's destructor was called.
Press any key to continue


Any information anyone can give me would be greatly appreicated. Smile | :)
Thanks.
- Michael
AnswerRe: Destructor not getting rid of the instance? Pin
Michael Dunn17-Oct-04 10:28
sitebuilderMichael Dunn17-Oct-04 10:28 
AnswerRe: Destructor not getting rid of the instance? Pin
Mike Dimmick17-Oct-04 12:22
Mike Dimmick17-Oct-04 12:22 
AnswerRe: Destructor not getting rid of the instance? Pin
Tim Smith17-Oct-04 14:45
Tim Smith17-Oct-04 14:45 
AnswerRe: Destructor not getting rid of the instance? Pin
Marc Clifton18-Oct-04 4:24
mvaMarc Clifton18-Oct-04 4:24 
GeneralNeed help to clear text, which I draw over the desktop Pin
vfilll17-Oct-04 9:46
vfilll17-Oct-04 9:46 
GeneralRe: Need help to clear text, which I draw over the desktop Pin
Blake Miller18-Oct-04 6:46
Blake Miller18-Oct-04 6:46 
GeneralRe: Need help to clear text, which I draw over the desktop Pin
vfilll18-Oct-04 7:42
vfilll18-Oct-04 7:42 
GeneralCreate email account Pin
Waleed Zedan17-Oct-04 9:32
Waleed Zedan17-Oct-04 9:32 
GeneralRe: Create email account Pin
ThatsAlok17-Oct-04 20:08
ThatsAlok17-Oct-04 20:08 
Generalevaluation period Pin
Anonymous17-Oct-04 6:45
Anonymous17-Oct-04 6:45 
GeneralRe: evaluation period Pin
Maximilien17-Oct-04 9:20
Maximilien17-Oct-04 9:20 
GeneralRe: evaluation period Pin
Anonymous17-Oct-04 13:14
Anonymous17-Oct-04 13:14 
GeneralRe: evaluation period Pin
David Crow18-Oct-04 3:23
David Crow18-Oct-04 3:23 
Generalpush like checkbox Pin
jooo17-Oct-04 6:23
jooo17-Oct-04 6:23 
GeneralRe: push like checkbox Pin
toxcct17-Oct-04 21:18
toxcct17-Oct-04 21:18 
GeneralNew to the boards Pin
Killer Coding Ninja Monkey17-Oct-04 6:20
Killer Coding Ninja Monkey17-Oct-04 6:20 
GeneralRe: New to the boards Pin
Anonymous17-Oct-04 6:37
Anonymous17-Oct-04 6:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.