C++Tutorial for Beginners 31 - Constructors and Destructors

preview_player
Показать описание
-------------------------------------------------------------------------------------------------------------------------------------------
Constructors and Destructors are special methods that are run when your objects are created and destroyed respectively. You can use constructors to initialize your objects.
--------------------------------------------------------------------------------------------------------------------------------------------
Рекомендации по теме
Комментарии
Автор

I am loving this tutorial series. As someone who has mainly worked in Python for the last 3 years, C++ is quite the change of pace and reading "The C++ Programming Language" Left clarification to be desired. Thanks for putting this all together!

johnlonai
Автор

i've got to say, your explaining skills are god tier, really appreciate your work :)

eyupsultanhem
Автор

"I don't really wanna talk about cats getting destroyed" haha!

nortski
Автор

Once again... great tutorials!!! Thanks.

ignabelitzky
Автор

really nice!
Following the whole tutorial :) Just love your humor and your way of explaining things.
I am so thankful that you give so many people the chance to learn computer topics. You're far better than any of my teacher at university! thanks dude :)

MisterPubichair
Автор

Hi John, I have a problem with destructor. I use visual studio 2015. When I create a instance of a certain class, the constructor normally runs but the destructor does not run after the whole program finishes. And I have to put a statement that says "instance.destructor();" to run the destructor. How can I fix this problem?

乌雅成璧-gm
Автор

Hi Cave of Programming! Listen in the next semester I am going to go through course called "object Oriented C++" in my university. Are these tutorials by any chance going to cover the stuff that I will have there?

P.S I love these. At the end of each video I get a question in my mind and next video literally answers that.

GorgianSoldier
Автор

cat::cat() {
cout << "Creating Cat" << endl;
happy = true;
}

cat::~cat() {
cout << "Cat Destroyed" << endl;
happy = false;
}

// I didn't think the cat would be happy any more after being destroyed...

MrSaxonHall
Автор

Hi John,
I was trying this,
"#include <iostream>
#include "Kitty.h"

using namespace std;

int main() {
cout << "Beginning dog creation!" << endl;
cout << "What is your dogs name? > " << flush;
Dog input;
cin >> input;

cout << "Hello " << input << endl;




}
"
It gave me a few errors. I was just curious if what I did was a possible. (I was trying to let the user name the dog. Do you happen to have an e-mail so I could message you the .h and .cpp?

sirmrtyler
Автор

Why do we need the semicolon in the .h file after the class function but not any other function?

大地奥田-ut
Автор

Are there any basic uses for destructors?

nathanlo
Автор

is an instance of an object still destroyed if there is no destructor?

blakedenham