• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 11:40
CEST 17:40
KST 00:40
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Code S Season 1 - RO8 Preview4[ASL21] Ro8 Preview Pt2: Progenitors8Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10
Community News
Maestros of The Game 2 announcement and schedule !7Weekly Cups (April 27-May 4): Clem takes triple0RSL Revival: Season 5 - Qualifiers and Main Event12Code S Season 1 (2026) - RO12 Results12026 GSL Season 1 Qualifiers25
StarCraft 2
General
Code S Season 1 - RO8 Preview Behind the Blue - Team Liquid History Book Weekly Cups (April 27-May 4): Clem takes triple Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Code S Season 1 (2026) - RO12 Results
Tourneys
Maestros of The Game 2 announcement and schedule ! GSL Code S Season 1 (2026) Sea Duckling Open (Global, Bronze-Diamond) RSL Revival: Season 5 - Qualifiers and Main Event Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players
External Content
Mutation # 524 Death and Taxes The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base
Brood War
General
Do we have a pimpest plays list? Why there arent any 256x256 pro maps? BGH Auto Balance -> http://bghmmr.eu/ (Spoiler) Asl ro8 D winner interview BW General Discussion
Tourneys
Escore Tournament StarCraft Season 2 [ASL21] Ro8 Day 4 Small VOD Thread 2.0 [BSL22] RO16 Group Stage - 02 - 10 May
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile Nintendo Switch Thread OutLive 25 (RTS Game) Dawn of War IV
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
European Politico-economics QA Mega-thread The Letting Off Steam Thread US Politics Mega-thread Canadian Politics Mega-thread Russo-Ukrainian War Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
How EEG Data Can Predict Gam…
TrAiDoS
ramps on octagon
StaticNine
Funny Nicknames
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1720 users

The Big Programming Thread - Page 194

Forum Index > General Forum
Post a Reply
Prev 1 192 193 194 195 196 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Hairy
Profile Joined February 2011
United Kingdom1169 Posts
Last Edited: 2012-11-15 10:41:31
November 15 2012 10:38 GMT
#3861
I don't quite understand the confusion happening here...

Pointers are variables, just like an int / bool etc are. Variables hold values. Pointers are not magical or scary, they are just variables that hold a memory address. And, just like any variable, a pointer passed into a function will be passed by VALUE - the function gets a local copy of that variable. What does this mean for pointers?

Within our function, that memory address is still the same memory address of whatever we were pointing to. Its value is the same. If we dereference that pointer, we can meddle with the object it was 'aiming' at just like we normally can with pointers. However, if we change the value of the pointer in the function (the memory address it is 'aiming' at) those changes will NOT be echoed outside the function! Just like any other variable, if we pass a variable by value and then change its value those changes will be lost once the function ends. The pointer within the function will hold a new value (it will point at something new), while our original pointer outside the function will still hold its original value (it will still point to whatever it did before).

So, what do we do if we want a function to alter the VALUE of our pointer (alter the memory address it's aiming at)? Just like any other variable, if we want a function to change our original variable we either need to pass it by reference, or give a pointer to it. This is NO DIFFERENT for pointers (remember again that pointers are just normal variables that happen to hold a memory address).

I hope this helps.
Sometimes I sits and thinks, and sometimes I just sits
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
November 15 2012 10:39 GMT
#3862
On November 15 2012 19:15 Abductedonut wrote:
Show nested quote +
On November 15 2012 18:50 Tobberoth wrote:
On November 15 2012 18:33 Abductedonut wrote:
On November 15 2012 17:59 cowsrule wrote:
Care to elaborate on why those examples demonstrate the language is crap? I'd be interested in hearing that perspective based around the existence of pointers and references.


Sure! I updated my post actually explaining the error instead of letting people figure it out for themselves for the newer programmers who come to this thread looking for advice/etc.

Basically the idea is this. When you're learning C++ from the beginning, you're told that passing by reference (the &) for primitive types (int/char/float/double) is one way to make sure that you do not pass a copy of the variable to a function. That way, changes inside that function will actually change the variable permanently.

Later on, you're introduced to pointers (the *) and you're told that passing by reference is really just pointers "in the background." And if you pass pointers (again, the *) of primitive types to a function, then the changes remain permanent.

Now objects come along. Well, if I pass to a function a pointer to an object, shouldn't the changes I make to the object be permanent? That only makes sense, since passing pointers to primitives types made the changes permanent. However, that's not the case. Passing a pointer of an object passes that pointer by value (which does not even make sense).

To make matters worse, structs are treated differently.

So C++ in inconsistent in that sense. Why are my pointers to my objects being passed by value?

Once you learn that, you "know" how to get around it but it still does not make logical sense. With C - C "classes" and primitive types are all treated the same way. You pass a pointer to a "class" or a primitive type, the changes are permanent.

Wait, are you saying objects are passed by value by default in C++? (I haven't programmed C++ in a very long time). It seems to be logical that if you pass an object to a function, you would pass the pointer by value but that would be the same as passing the "object" by reference, so changes should be permanent. It seems weird to me that C++ would copy the whole object by default, just because a pointer to the object was sent by value (especially since it doesn't work like that in C#).


No, that's not what I'm saying. Look, the POINTER ITSELF is passed by value. So modifications to the POINTER ( if the pointer is pointing to the object that originally called the function, changes WILL remain permanent in the object ). However, any changes made to the pointer will not be changed. Let me provide an example.

Example:
+ Show Spoiler +

#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

class kitty
{
public:
int kittySize;
kitty();
kitty (const kitty& myKitty);
};

kitty::kitty ()
{
kittySize = 10;
}

kitty::kitty (const kitty& myKitty)
{
kittySize = -10;
}

void func(kitty*);

int main(int argc, char *argv[]
{
kitty *myAwesomeKitty = new kitty[1];
myAwesomeKitty->kittySize = 0;
func(myAwesomeKitty);
// Should this print as 0 or 10?
cout<<myAwesomeKitty->kittySize;
system("pause");
}

void func( kitty *myAwesomeKitty )
{
kitty myKitty;
myAwesomeKitty = &myKitty;
myAwesomeKitty->kittySize = 10;
}


Note in this case.. kittySize WILL BE PRINTED AS 0! Because we changed the VALUE of the pointer, any changes made to the pointers contents were discarded. Do you see how confusing this can get?

*edit* Going to bed for now... I could see how my other post is confusing. No, the changes to the object itself are preserved if you DO NOT modify the value of the pointer. But any changes made to the pointer are discarded because the pointer itself is being passed by value

Also, to the poster above me... thanks. I obviously don't know C++ when I pointed out the mistake of the original guy I quoted and proceeded to explain stuff to others. It's pretty easy to come in here and say "he doesn't know what he's talking about." If you're so great at C++ why don't you explain things?

That's what I expected, but how can you call this inconsistent? The pointer, which is comparable to an int containing a number which is an address to a point in memory, is passed by value. This is consistent, because primitive types are passed by value in C++. Confusing? Sure, if you don't understand what a pointer is and how C++ handles parameters, it might be surprising that changing the pointer itself has no permanent effect, while changing the object does. Surprising and slightly confusing? Sure. Inconsistent? No, I can't agree with that.
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
November 15 2012 10:40 GMT
#3863
Guys... the point is not whether it makes sense to YOU or not. My point is that it's incredibly confusing to most programmers which thus leads to shitty/wrong code. Of course it's consistent with itself.

Also, i am not confused nor do i have a bad understanding of pointers. Read the thread. I'm trying to explain it to others.
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
November 15 2012 10:44 GMT
#3864
On November 15 2012 19:40 Abductedonut wrote:
Guys... the point is not whether it makes sense to YOU or not. My point is that it's incredibly confusing to most programmers which thus leads to shitty/wrong code. Of course it's consistent with itself.

Also, i am not confused nor do i have a bad understanding of pointers. Read the thread. I'm trying to explain it to others.

Well, the problem is that you wrote that C++ is a trash language because it's inconsistent, which it isn't (at least in your example). It would be different if you wrote that C++ is a trash language because it's confusing to programmers who aren't very good at it.
Hairy
Profile Joined February 2011
United Kingdom1169 Posts
November 15 2012 10:52 GMT
#3865
On November 15 2012 19:40 Abductedonut wrote:
Guys... the point is not whether it makes sense to YOU or not. My point is that it's incredibly confusing to most programmers which thus leads to shitty/wrong code. Of course it's consistent with itself.

Also, i am not confused nor do i have a bad understanding of pointers. Read the thread. I'm trying to explain it to others.

To follow on from Tobberoth, also the fact that you said this:
If you supply to a function a pointer to an object, the changes made to that object get reverted once you exit the function

Which is completely untrue.
Sometimes I sits and thinks, and sometimes I just sits
Mstring
Profile Joined September 2011
Australia510 Posts
November 15 2012 10:54 GMT
#3866
On November 15 2012 19:40 Abductedonut wrote:
Guys... the point is not whether it makes sense to YOU or not. My point is that it's incredibly confusing to most programmers which thus leads to shitty/wrong code. Of course it's consistent with itself.

Also, i am not confused nor do i have a bad understanding of pointers. Read the thread. I'm trying to explain it to others.


I'm intrigued to know what *should* happen in your last example-- what a non-confusing output would be (what Most Programmer expected).
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
November 15 2012 10:56 GMT
#3867
On November 15 2012 19:52 Hairy wrote:
Show nested quote +
On November 15 2012 19:40 Abductedonut wrote:
Guys... the point is not whether it makes sense to YOU or not. My point is that it's incredibly confusing to most programmers which thus leads to shitty/wrong code. Of course it's consistent with itself.

Also, i am not confused nor do i have a bad understanding of pointers. Read the thread. I'm trying to explain it to others.

To follow on from Tobberoth, also the fact that you said this:
Show nested quote +
If you supply to a function a pointer to an object, the changes made to that object get reverted once you exit the function

Which is completely untrue.


Yes you're right. That should be pointer. My bad. Will change that tomorrow once i'm not typing from a crappy phone =P Thanks for pointing that out to me.
mcc
Profile Joined October 2010
Czech Republic4646 Posts
November 15 2012 10:56 GMT
#3868
On November 15 2012 19:40 Abductedonut wrote:
Guys... the point is not whether it makes sense to YOU or not. My point is that it's incredibly confusing to most programmers which thus leads to shitty/wrong code. Of course it's consistent with itself.

Also, i am not confused nor do i have a bad understanding of pointers. Read the thread. I'm trying to explain it to others.

It is confusing to programmers who do not understand pointers, might be. But that does not make C++ shitty as you cannot make pointers in any other way for them to be internally consistent. So your C++ bashing is completely nonsensical.
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
November 15 2012 11:01 GMT
#3869
On November 15 2012 19:54 Mstring wrote:
Show nested quote +
On November 15 2012 19:40 Abductedonut wrote:
Guys... the point is not whether it makes sense to YOU or not. My point is that it's incredibly confusing to most programmers which thus leads to shitty/wrong code. Of course it's consistent with itself.

Also, i am not confused nor do i have a bad understanding of pointers. Read the thread. I'm trying to explain it to others.


I'm intrigued to know what *should* happen in your last example-- what a non-confusing output would be (what Most Programmer expected).


You do realize most of the times when that mistake is made it's not in such a trivial and well written case, right?

Most programmers would expect the original objects size to change. When they not-so-obviously change the value of the pointer ( think after using something like strtok() ), it becomes hard to track. Most programmers have trouble with basic pointers to begin with... let alone passing pointers by value.
Mstring
Profile Joined September 2011
Australia510 Posts
November 15 2012 11:14 GMT
#3870
On November 15 2012 20:01 Abductedonut wrote:
Show nested quote +
On November 15 2012 19:54 Mstring wrote:
On November 15 2012 19:40 Abductedonut wrote:
Guys... the point is not whether it makes sense to YOU or not. My point is that it's incredibly confusing to most programmers which thus leads to shitty/wrong code. Of course it's consistent with itself.

Also, i am not confused nor do i have a bad understanding of pointers. Read the thread. I'm trying to explain it to others.


I'm intrigued to know what *should* happen in your last example-- what a non-confusing output would be (what Most Programmer expected).


You do realize most of the times when that mistake is made it's not in such a trivial and well written case, right?

Most programmers would expect the original objects size to change. When they not-so-obviously change the value of the pointer ( think after using something like strtok() ), it becomes hard to track. Most programmers have trouble with basic pointers to begin with... let alone passing pointers by value.


I think that if you intend a parameter to be used for returning values you should use a reference or a const pointer. Then you can't make this mistake-- it won't compile.

Most Starcraft players can't cleanly execute a basic two base build; doesn't mean Starcraft sucks; everyone just sucks at it :D
Bigpet
Profile Joined July 2010
Germany533 Posts
November 15 2012 11:27 GMT
#3871
Abductedonut, I really don't know what you're getting at,C++ is entirely consistent in the pointer/reference/value semantics and just like MString I'm very intrigued as to what you think should happen instead. Also, the examples you provide aren't idiomatic C++ anymore, you can't write some weird C with C++ mash and then blame C++ for how confusing it is. That's like writing Java code with block labels and abusing runtime exceptions for returning values and other shenanigans and then blame Java that it's confusing.
I'm NOT the caster with a similar nick
Schokomuesli
Profile Joined November 2010
Germany12 Posts
November 15 2012 11:31 GMT
#3872
If you have a problem discerning betwenn an object and a pointer to an object you should not use a language that allows major fiddling with those things. It's really that simple. Furthermore, if you have problems discerning those very different things you really do not need the performance increase (if there is any at all considering how good compilers are these days) these options give you. Use a managed language instead.

Besides: the examples you gave are "C with classes" but in no way modern C++ code.
netherh
Profile Blog Joined November 2011
United Kingdom333 Posts
November 15 2012 11:37 GMT
#3873
On November 15 2012 20:01 Abductedonut wrote:
Show nested quote +
On November 15 2012 19:54 Mstring wrote:
On November 15 2012 19:40 Abductedonut wrote:
Guys... the point is not whether it makes sense to YOU or not. My point is that it's incredibly confusing to most programmers which thus leads to shitty/wrong code. Of course it's consistent with itself.

Also, i am not confused nor do i have a bad understanding of pointers. Read the thread. I'm trying to explain it to others.


I'm intrigued to know what *should* happen in your last example-- what a non-confusing output would be (what Most Programmer expected).


You do realize most of the times when that mistake is made it's not in such a trivial and well written case, right?

Most programmers would expect the original objects size to change. When they not-so-obviously change the value of the pointer ( think after using something like strtok() ), it becomes hard to track. Most programmers have trouble with basic pointers to begin with... let alone passing pointers by value.


I disagree with your assessment of what programmers find hard. Understanding pointers isn't hard. Memory management is a much more problematic area - as demonstrated nicely in your example where you forget to use delete.

Another issue is that people use pointers where they shouldn't. References should be used wherever possible instead of pointers, and where you do have pointers, you should probably be using shared_ptr / weak_ptr / scoped_ptr to make it clear who owns it, and eliminate problems with memory management.

There's also a problem with people using C style things in C++, and not using the much better options available. Why the hell would someone ever use strtok() when you have boost string algorithms, boost tokenizer, or even stringstreams and getline()?
heishe
Profile Blog Joined June 2009
Germany2284 Posts
Last Edited: 2012-11-15 11:42:18
November 15 2012 11:41 GMT
#3874
On November 15 2012 19:56 mcc wrote:
Show nested quote +
On November 15 2012 19:40 Abductedonut wrote:
Guys... the point is not whether it makes sense to YOU or not. My point is that it's incredibly confusing to most programmers which thus leads to shitty/wrong code. Of course it's consistent with itself.

Also, i am not confused nor do i have a bad understanding of pointers. Read the thread. I'm trying to explain it to others.

It is confusing to programmers who do not understand pointers, might be. But that does not make C++ shitty as you cannot make pointers in any other way for them to be internally consistent. So your C++ bashing is completely nonsensical.


Even more so because pointers are just one feature of the language, which, additionally, can (and should) be avoided a large majority of the time. In fact, thanks to templates and things like smart_ptr, if you start a project from scratch you only have a starting phase where you can write a basic framework for your project, make sure that the framework only deals with references when interfacing to the outside and from that point on you can literally code without seeing "type*" ever again, with the code looking much like Java code, just running a lot faster. And all of that without having to worry about leaking memory or undefined behaviour.
If you value your soul, never look into the eye of a horse. Your soul will forever be lost in the void of the horse.
Nausea
Profile Joined October 2010
Sweden807 Posts
November 15 2012 12:43 GMT
#3875
On November 15 2012 20:31 Schokomuesli wrote:
If you have a problem discerning betwenn an object and a pointer to an object you should not use a language that allows major fiddling with those things. It's really that simple. Furthermore, if you have problems discerning those very different things you really do not need the performance increase (if there is any at all considering how good compilers are these days) these options give you. Use a managed language instead.

Besides: the examples you gave are "C with classes" but in no way modern C++ code.


So if I did C_Player player;
Shade.OnLoad(&player, 0.5)

Then inside OnLoad
targetptr = target(name of the param of the passed object)
this->X = targetptr->X;

Should this not work? Because, it does not at the moment, and only with this function.
Set it ablaze!
Schokomuesli
Profile Joined November 2010
Germany12 Posts
November 15 2012 13:07 GMT
#3876
Just to get it right... What you are doing is:

{
(...)
C_Player player;
Shade.OnLoad(&player, 0.5f);
(...)
}

and inside Shade.OnLoad() you copy a value in player to a local variable in Shade, right? Furthermore: is the pointer you passed into OnLoad still valid when using it? In particular: do you use if after leaving the scope in which you created player (that is: the closing curly brace just below OnLoad ^)? Because after this brace, player does not exist anymore if you create it on the stack as you did in the example above...

If you do _excatly_ this:

{
C_Player player;
Shade.OnLoad(&player, 0.5f);
}

^and never again use anything inside Shade which refers to the pointer you passed you are fine and all of this should work.

If you do this:

{
{
C_Player player;
C_Player* player2 = new C_Player();
Shade.OnLoad(&player, 0.5f);
Shade.OnLoad(player2, 0.5f);
}
Shade.asdf1(); // asdf1 uses the pointer to player you passed /w onLoad before - this breaks
Shade.asdf2(); // asdf2 uses the pointer to player2 you passed /w onLoad before - this works because due to heap construction, the object player2 points to still exists...
}

This will not work... player does not exist anymore but you still have the adress where it used to reside before leaving the scope you created it in.

BTW, this is just guesswork without seeing the methods and the surrounding code...
Nausea
Profile Joined October 2010
Sweden807 Posts
Last Edited: 2012-11-15 13:23:35
November 15 2012 13:22 GMT
#3877
+ Show Spoiler +
On November 15 2012 22:07 Schokomuesli wrote:
Just to get it right... What you are doing is:

{
(...)
C_Player player;
Shade.OnLoad(&player, 0.5f);
(...)
}

and inside Shade.OnLoad() you copy a value in player to a local variable in Shade, right? Furthermore: is the pointer you passed into OnLoad still valid when using it? In particular: do you use if after leaving the scope in which you created player (that is: the closing curly brace just below OnLoad ^)? Because after this brace, player does not exist anymore if you create it on the stack as you did in the example above...

If you do _excatly_ this:

{
C_Player player;
Shade.OnLoad(&player, 0.5f);
}

^and never again use anything inside Shade which refers to the pointer you passed you are fine and all of this should work.

If you do this:

{
{
C_Player player;
C_Player* player2 = new C_Player();
Shade.OnLoad(&player, 0.5f);
Shade.OnLoad(player2, 0.5f);
}
Shade.asdf1(); // asdf1 uses the pointer to player you passed /w onLoad before - this breaks
Shade.asdf2(); // asdf2 uses the pointer to player2 you passed /w onLoad before - this works because due to heap construction, the object player2 points to still exists...
}

This will not work... player does not exist anymore but you still have the adress where it used to reside before leaving the scope you created it in.

BTW, this is just guesswork without seeing the methods and the surrounding code...


Thanks, but C_Player player is from C_Application.h and then implemented inside applications OnInit funktion. This should lead player to "die" at the end of the program, like every entity in my entitylist. I have tried making player dynamic, this did not work either. This is why I am confused atm.
Set it ablaze!
Schokomuesli
Profile Joined November 2010
Germany12 Posts
November 15 2012 13:27 GMT
#3878
^OK, then I have absolutely no clue... gl in finding the error, though...
Nausea
Profile Joined October 2010
Sweden807 Posts
November 15 2012 13:29 GMT
#3879
On November 15 2012 22:27 Schokomuesli wrote:
^OK, then I have absolutely no clue... gl in finding the error, though...


Hehe thanks anyway
Set it ablaze!
Bigpet
Profile Joined July 2010
Germany533 Posts
Last Edited: 2012-11-15 13:46:32
November 15 2012 13:45 GMT
#3880
On November 15 2012 22:22 Nausea wrote:
+ Show Spoiler +
On November 15 2012 22:07 Schokomuesli wrote:
Just to get it right... What you are doing is:

{
(...)
C_Player player;
Shade.OnLoad(&player, 0.5f);
(...)
}

and inside Shade.OnLoad() you copy a value in player to a local variable in Shade, right? Furthermore: is the pointer you passed into OnLoad still valid when using it? In particular: do you use if after leaving the scope in which you created player (that is: the closing curly brace just below OnLoad ^)? Because after this brace, player does not exist anymore if you create it on the stack as you did in the example above...

If you do _excatly_ this:

{
C_Player player;
Shade.OnLoad(&player, 0.5f);
}

^and never again use anything inside Shade which refers to the pointer you passed you are fine and all of this should work.

If you do this:

{
{
C_Player player;
C_Player* player2 = new C_Player();
Shade.OnLoad(&player, 0.5f);
Shade.OnLoad(player2, 0.5f);
}
Shade.asdf1(); // asdf1 uses the pointer to player you passed /w onLoad before - this breaks
Shade.asdf2(); // asdf2 uses the pointer to player2 you passed /w onLoad before - this works because due to heap construction, the object player2 points to still exists...
}

This will not work... player does not exist anymore but you still have the adress where it used to reside before leaving the scope you created it in.

BTW, this is just guesswork without seeing the methods and the surrounding code...


Thanks, but C_Player player is from C_Application.h and then implemented inside applications OnInit funktion. This should lead player to "die" at the end of the program, like every entity in my entitylist. I have tried making player dynamic, this did not work either. This is why I am confused atm.


Then what exactly is strange in your program then? Explaining it in words is kind of hard to understand. You should post some code example. Btw. if your problem is that the pointer is slightly offset then that may be due to multiple inheritance if you use that. Don't let us puzzle, post a self contained example.


#include <iostream>

class Base{public: long padding;};
class Base2{};
class Derived : public Base, public Base2{};

int main(){
Derived d;
Derived *ptr = &d;
Base2 *bas = static_cast<Base2 *>(ptr);
if((void *)ptr != (void *)bas){
std::cout << "the wonders of multiple inheritance" << std::endl;
}
return 0;
}
I'm NOT the caster with a similar nick
Prev 1 192 193 194 195 196 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 20m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Serral 3901
RotterdaM 278
TKL 124
StarCraft: Brood War
Britney 43302
Bisu 2169
EffOrt 906
Larva 558
firebathero 550
Hyuk 500
Stork 476
ggaemo 416
Mini 352
BeSt 304
[ Show more ]
actioN 267
ZerO 218
Soulkey 209
hero 185
Killer 177
Rush 167
Hyun 90
Pusan 82
Dewaltoss 75
Zeus 57
Sharp 57
Barracks 55
Backho 54
Sea.KH 48
ToSsGirL 32
soO 27
sorry 22
HiyA 20
Shine 19
scan(afreeca) 18
Rock 16
IntoTheRainbow 15
Terrorterran 13
GoRush 13
ajuk12(nOOB) 10
Noble 9
Sacsri 8
Dota 2
Gorgc4800
qojqva1982
syndereN480
monkeys_forever184
Counter-Strike
fl0m359
Heroes of the Storm
MindelVK1
Other Games
singsing2065
B2W.Neo1104
hiko838
Liquid`RaSZi758
FrodaN643
Beastyqt511
Lowko348
DeMusliM347
ceh9278
ArmadaUGS177
KnowMe176
Mew2King93
QueenE65
Trikslyr31
ZerO(Twitch)15
fpsfer 1
Organizations
Other Games
gamesdonequick1686
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 15 non-featured ]
StarCraft 2
• poizon28 25
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• HerbMon 20
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis3584
• TFBlade939
Other Games
• Shiphtur163
Upcoming Events
Big Brain Bouts
20m
Fjant vs Bly
Serral vs Shameless
OSC
6h 20m
The PiG Daily
7h 20m
Maru vs Rogue
TBD vs Classic
herO vs Solar
ByuN vs Solar
Replay Cast
8h 20m
CranKy Ducklings
18h 20m
RSL Revival
18h 20m
SHIN vs Bunny
ByuN vs Shameless
WardiTV Invitational
19h 20m
Krystianer vs TriGGeR
Cure vs Rogue
SC Evo League
21h 20m
uThermal 2v2 Circuit
23h 20m
BSL
1d 3h
Artosis vs TerrOr
spx vs StRyKeR
[ Show More ]
Replay Cast
1d 8h
Sparkling Tuna Cup
1d 18h
RSL Revival
1d 18h
Cure vs Zoun
Clem vs Lambo
WardiTV Invitational
1d 19h
BSL
2 days
Dewalt vs DragOn
Aether vs Jimin
GSL
2 days
Afreeca Starleague
2 days
Soma vs Leta
Wardi Open
2 days
Monday Night Weeklies
3 days
OSC
3 days
CranKy Ducklings
3 days
Afreeca Starleague
3 days
Light vs Flash
Replay Cast
4 days
Replay Cast
5 days
The PondCast
5 days
Replay Cast
6 days
RSL Revival
6 days
Liquipedia Results

Completed

Proleague 2026-05-05
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Acropolis #4
Escore Tournament S2: W6
SCTL 2026 Spring
RSL Revival: Season 5
2026 GSL S1
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2

Upcoming

KK 2v2 League Season 1
BSL 22 Non-Korean Championship
YSL S3
Escore Tournament S2: W7
Escore Tournament S2: W8
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
BLAST Bounty Summer 2026: Closed Qualifier
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.