Can a class with out any instances present have it static members
updated.
If yes, on which object does the update happen.
-Parag 5 1491
On 2007-12-18 15:00:56 -0500, "pa********@hot mail.com"
<pa********@hot mail.comsaid:
Can a class with out any instances present have it static members
updated.
Yes.
>
If yes, on which object does the update happen.
None. Static member variables belong to the class, not to any object.
--
-kira
On Dec 19, 1:00 am, "parag_p...@hot mail.com" <parag_p...@hot mail.com>
wrote:
Can a class with out any instances present have it static members
updated.
If yes, on which object does the update happen.
-Parag
But yes one needs to make sure that they are initialized once before
any usage.
The initialization makes sure that the memory is allocated for the
static member variables.
Any usage of static member variables without initialization could
cause unresolved external symbol linker error...
On Dec 19, 4:45 am, Rahul <sam_...@yahoo. co.inwrote:
On Dec 19, 1:00 am, "parag_p...@hot mail.com"
<parag_p...@hot mail.comwrote:
Can a class with out any instances present have it static
members updated.
If yes, on which object does the update happen.
But yes one needs to make sure that they are initialized once
before any usage.
That's true for most variables, but not for static POD types,
which are automatically zero initialized before any code is run.
The initialization makes sure that the memory is allocated for
the static member variables.
The initialization of a static variable has nothing to do with
memory allocation.
Any usage of static member variables without initialization
could cause unresolved external symbol linker error...
You'll likely get an unresolved external symbol error from the
linker if you fail to define the symbol, but the linker doesn't
care in the least about initialization.
--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
On Dec 19, 3:00 pm, James Kanze <james.ka...@gm ail.comwrote:
On Dec 19, 4:45 am, Rahul <sam_...@yahoo. co.inwrote:
On Dec 19, 1:00 am, "parag_p...@hot mail.com"
<parag_p...@hot mail.comwrote:
Can a class with out any instances present have it static
members updated.
If yes, on which object does the update happen.
But yes one needs to make sure that they are initialized once
before any usage.
That's true for most variables, but not for static POD types,
which are automatically zero initialized before any code is run.
The initialization makes sure that the memory is allocated for
the static member variables.
The initialization of a static variable has nothing to do with
memory allocation.
What is the initialization meant for?
>
Any usage of static member variables without initialization
could cause unresolved external symbol linker error...
You'll likely get an unresolved external symbol error from the
linker if you fail to define the symbol, but the linker doesn't
care in the least about initialization.
--
James Kanze (GABI Software) email:james.ka. ..@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Rahul wrote:
On Dec 19, 3:00 pm, James Kanze <james.ka...@gm ail.comwrote:
>On Dec 19, 4:45 am, Rahul <sam_...@yahoo. co.inwrote:
>>On Dec 19, 1:00 am, "parag_p...@hot mail.com" <parag_p...@h otmail.comwrote : Can a class with out any instances present have it static members updated. If yes, on which object does the update happen. But yes one needs to make sure that they are initialized once before any usage.
That's true for most variables, but not for static POD types, which are automatically zero initialized before any code is run.
>>The initialization makes sure that the memory is allocated for the static member variables.
The initialization of a static variable has nothing to do with memory allocation.
What is the initialization meant for?
To initialise the state of the variable, just like any other. Leaving a
static member uninitialised doesn't mean it's not there.
--
Ian Collins. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Erik Bongers |
last post by:
Hi,
Nested classes only seem to be able to access static members of the
surrounding class :
class SurroundingClass
{
public:
class InnerClass
{
public:
|
by: Steven T. Hatton |
last post by:
This is a purely *hypothetical* question. That means, it's /pretend/,
CP. ;-)
If you were forced at gunpoint to put all your code in classes, rather than
in namespace scope (obviously classes themselves are an exception to this),
and 'bootstrap' your program by instantiating a single application object
in main(), would that place any limitations on what you could accomplish
with your program? Are there any benefits to doing things that...
|
by: kuvpatel |
last post by:
Hi
I want to refer a class called LogEvent, and use one of its methods called
WriteMessage without actually having to create an instance of Logevent.
I have tried using the word sealed with the class and this works but I would
also like to know of other ways to do this.
Also are there any performance implacations of using sealed?
|
by: Kevin Prichard |
last post by:
Hi all,
I've recently been following the object-oriented techiques discussed
here and have been testing them for use in a web application. There is
problem that I'd like to discuss with you experts.
I would like to produce Javascript classes that can be "subclassed"
with certain behaviors defined at subclass time. There are plenty of
ways to do this through prototyping and other techniques, but these
behaviors need to be static and...
|
by: JC |
last post by:
Suppose an ASP.Net project contains a public static class with public
methods and members that are used throughout the application. Of course
being static, there is only copy of the class within the application.
Now suppose two users access the Web site simultaneously. Does each
user see his/her own single copy of the static class, or do they
share the class, thus creating a problem that can only be solved
if one use blocks the other...
| |
by: chameleon |
last post by:
I have 2 classes with exactly the same members (all static except
dtor/ctor).
Classes have different implementantion in only one static member
function and first class has one more member function.
How can I write this code with templates?
First of all: Thought to write code with templates is correct?
members of classes are static because refer to devices. There is no
reason to be non-static.
|
by: puzzlecracker |
last post by:
Would you quickly remind me the difference between, regular class,
static class, and nested class?
Thanks
|
by: Andy B |
last post by:
I have a class that I want to make static but it uses some objects that are
instance objects. I keep getting a compiler error saying something about
using instance objects in a static class or method is not allowed. How do
you do this if you really need a static class but also have to use these
instance objects in them? If you need a simple example of what I am trying
to do, it is below:
imports Data.EternityRecordsEntities
namespace...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |