C++ Questions
Hello :)
I started learning some C++ and I think that I have problem of either understanding the real meaning. So my first question, I know pointers refers to variable address in memory like: PHP Code:
PHP Code:
because when I checked some HL or HL2 SDK files, I found out that for example they declare Entity like this: PHP Code:
PHP Code:
What I understand is that we should use it when we have an Array and dont know it's size so we do for example like this: PHP Code:
PHP Code:
PHP Code:
|
Re: C++ Questions
To answer the first question:
In C++, to do most meaningful things with objects, you must use pointers. This includes fancy things like calling constructors that take arguments. This is because C++ uses the Resource Aquisition Is Initialization. That is, just declaring a variable of a class instantiates it using the no argument constructor. Unless it's a pointer. It's also not possible to do Polymorphism in C++ without using pointers... Code:
// This is always a CBaseEntity class |
Re: C++ Questions
Quote:
Quote:
|
Re: C++ Questions
When I said "or any of its children" I meant child classes.
Like how CBaseCombatWeapon or CBasePlayer are child classes of CBaseEntity. Code:
CBaseEntity *pEntity; |
Re: C++ Questions
Quote:
Quote:
Quote:
Quote:
|
Re: C++ Questions
Quote:
Quote:
|
Re: C++ Questions
Quote:
PHP Code:
Quote:
Also, if you don't free dynamically allocated memory, you get the so-called memory leak (I am certain you've heard of it). PHP Code:
|
Re: C++ Questions
I'll try it tomorrow since I am playing a little bit now, and I'll tell you man, thank you for your work!
|
Re: C++ Questions
Quote:
I saw these, these are just a definition tbh, I understand what a pointer is but I dont understand what is the point of using it if you know whay I mean, we can simple get adress of variable by using & operator instead of make in it a pointer, I mean we can convert anything we want. |
| All times are GMT -4. The time now is 08:50. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.