LightBrain website relaunched, BomberFUN only USD 9.99
visit http://www.lightbrain.de
int main()
{
employee_s BobSmith;
float hours; // used for something else, say...
// tracking the current time or whatever..
// hypothetical situation regardless.
with(BobSmith)
{
hours = 10; // beep beep beep. we have a scope problem.
}
return 0;
}
int main()
{
employee_s BobSmith;
float hours; // used for something else, say...
// tracking the current time or whatever..
// hypothetical situation regardless.
with(BobSmith)
{
::hours = 10; // the scope resolution operator by
// itself would differentiate itself
// from the "hours" we created inside
// the scope of main()
hours = 24; // using a 24 hour clock! and no scoping problems.
}
return 0;
}

Do NOT let Dr. Mario touch your genitals. He is not a real doctor!
[EDIT by Oluseyi: Comments widening page.]
[edited by - Oluseyi on May 13, 2003 10:43:56 AM]
quote:
m_wcWeaponControl.wsWeaponSystem[m_iWeapon].fDelayBetweenShoots = 0.2f;
m_wcWeaponControl.wsWeaponSystem[m_iWeapon].vct3Speed.x = 40.f;
m_wcWeaponControl.wsWeaponSystem[m_iWeapon].vct3PositionAdd.x = 2.5f;
m_wcWeaponControl.wsWeaponSystem[m_iWeapon].vct3PositionAdd.y = 0.475f;
m_wcWeaponControl.wsWeaponSystem[m_iWeapon].vct3PositionAdd.z = 0.0f;
...
This is ugly.
quote:
Original post by flangazor
Don''t use a pointer. Use a reference.
quote:You use the scope resolution operator, ::. Are you people asleep or do you not know the language?
Original post by daerid
yes, but what happens if you want to use a variable declared outside the with block that has the same identifier as a member variable?
quote:
Original post by Oluseyi
You use the scope resolution operator, ::. Are you people asleep or do you not know the language?
quote:
C++ doesn''t need a with statement. with is just a tool for assuaging guilt over a poor design in most instances.
quote:
Original post by TroneX
This might look something like this:
m_wcWeaponControl.wsWeaponSystem[m_iWeapon].fDelayBetweenShoots = 0.2f;
m_wcWeaponControl.wsWeaponSystem[m_iWeapon].vct3Speed.x = 40.f;
m_wcWeaponControl.wsWeaponSystem[m_iWeapon].vct3PositionAdd.x = 2.5f;
m_wcWeaponControl.wsWeaponSystem[m_iWeapon].vct3PositionAdd.y = 0.475f;
m_wcWeaponControl.wsWeaponSystem[m_iWeapon].vct3PositionAdd.z = 0.0f;
...
This is ugly.
quote:
So isn''t there something like a with statement in C++ (Pascal had that, imho)
with'' construct is idiotic. It causes some remote lexical scope to be combined with the current scope in a way that changes to one piece of code can affect a lexically unrelated scope. If it''s language idiocy you''re after, then C++ introduces the idea of class scope'', where a class - the building block for object systems - also denotes a scope. Similar to Pascal''s with'', class scope allows you to change the meaning of some piece of code from some lexically distinct other piece of code. Google Law of Demeter'' to find out how to solve your problem.This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more