[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] [Bug #1613] Classes with only one instance
From: |
nobody |
Subject: |
[Pingus-CVS] [Bug #1613] Classes with only one instance |
Date: |
Mon, 04 Nov 2002 21:00:16 -0500 |
=================== BUG #1613: FULL BUG SNAPSHOT ===================
http://savannah.nongnu.org/bugs/?func=detailbug&bug_id=1613&group_id=2184
Submitted by: hfmanson Project: Pingus
Submitted on: 2002-Nov-05 02:00
Category: None Severity: 5 - Major
Bug Group: None Resolution: None
Assigned to: None Status: Open
Release: 0.5.0-CVS Platform Version: All
Planned Release: None
Summary: Classes with only one instance
Original Submission: I have the following proposal to change classes with only
one instance e.g. ScreenManager as follows (an example):
class InstanceClass
{
public:
int x;
int y;
static InstanceClass instance;
InstanceClass() : x(3), y(4) { }
~InstanceClass()
{
printf("cleaning up\n");
}
};
InstanceClass InstanceClass::instance;
int main(int argc, char* argv[])
{
printf("%d %d \n", InstanceClass::instance.x, InstanceClass::instance.y);
return 0;
}
The advantages are:
- No more need to implement init/deinit functions: the object is automatically
destroyed at program exit
- A direct object -> (slightly) better performance
I'm very curious what your opinion is.
This compiles under gcc and VC++
No Followups Have Been Posted
CC list is empty
No files currently attached
For detailed info, follow this link:
http://savannah.nongnu.org/bugs/?func=detailbug&bug_id=1613&group_id=2184
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] [Bug #1613] Classes with only one instance,
nobody <=