Great ... But could you explain why your using scope resolution (::) when accessing the total
@tong5364 Жыл бұрын
Thank you so much, this tutorial really really help me
@PortfolioCourses Жыл бұрын
You’re very welcome, I’m glad that it helped you out! :-)
@chenchen-eo4yf8 ай бұрын
Great video! but can you explain little bit why static variable can only be initialized outside of class?
@UnleashedCode27 күн бұрын
I too would like to know.... I did notice that you can initialize it using the 'inline' keyword: inline static int counter { 0 }; This compiles.... but I have seen inconsistencies with the counter results like this. Sometimes the counter starts negatively. No idea why.
@PEJOTAvix2 жыл бұрын
Great tutorial. Thank you! But I'm actually having troble with another thing. I'm trying to modularize my code into MVC. How to I acess a controller variable from my view cpp? The problem is that if I declare a controller class static variable outside my class declaration (as a global variable in my controller.cpp), that variable is not accessible from my view.cpp. How do I fix this? Do I have to pass variables or pointers as parametrs of class methods?
@PortfolioCourses2 жыл бұрын
Thanks Paulo! :-) That's a great question. I don't have a tutorial on this topic yet, but for the problem you're experiencing I would suggest looking up the topic "multifile projects in C++" as some of the tutorials out there around this topic may address what you're experiencing and/or trying to ultimately do. If you split the project up across .h and .cpp files that include one another in the correct way, what you're trying to do should be possible, but it's more than I think I can explain well in a comment. One day I will make a tutorial on this topic too, but I'm not sure when.
@PEJOTAvix2 жыл бұрын
Thanks! I will. I found a way to access the variables by declaring them in the controller.h as you suggested on this tutorial, initializing them in the controller.cpp and importing the controller.cpp in my view.cpp. But I don't know if importing a cpp file into another is a good practice, tho. I'll test it today and get back to tell you if everything works fine without any linker problems Thanks again and shoutout from Brazil!
@PortfolioCourses2 жыл бұрын
Sounds good! :-D
@pedllz2 жыл бұрын
Thank you!
@PortfolioCourses2 жыл бұрын
You're welcome Pablo! :-D
@didiTchu2 жыл бұрын
great as always, but you didnt explain the 'star' and the 'new' that you used
@PortfolioCourses2 жыл бұрын
Thanks! :-) These videos may help with those concepts: Introduction to Pointers: kzbin.info/www/bejne/aHinmot9areZhKc new and delete: kzbin.info/www/bejne/raDTdoaaert9qZY