473,387 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Possible Conflict?

Could the following code produce errors / unpredictable results?

static someClass *someVar = new someClass( );
Jul 22 '05 #1
4 978
"Trevor M. Lango" <tm*****@sbcglobal.net> wrote...
Could the following code produce errors / unpredictable results?

static someClass *someVar = new someClass( );


Of course. Oh, wait. Is that _all_ code there is? Then,
sorry, it doesn't compile -- 'someClass' is undefined.
Jul 22 '05 #2

"Trevor M. Lango" <tm*****@sbcglobal.net> wrote in message
news:48*****************@newssvr25.news.prodigy.co m...
Could the following code produce errors / unpredictable results?

static someClass *someVar = new someClass( );

Yes:

struct someClass {
someClass() {
reinterpret_cast< std::vector<int>*(this)->assign(1000000000, 0);

}
};

Jonathan.
Jul 22 '05 #3
On Wed, 04 Feb 2004 19:56:48 GMT, "Trevor M. Lango"
<tm*****@sbcglobal.net> wrote:
Could the following code produce errors / unpredictable results?

static someClass *someVar = new someClass( );


I suppose it would largely depend on what the default constructor of
"someClass" does. Can it throw an exception? Does it reserve tons of
resources? Does it try to dial up your internet provider?
--
Bob Hairgrove
No**********@Home.com
Jul 22 '05 #4
"Trevor M. Lango" <tm*****@sbcglobal.net> wrote:
Could the following code produce errors / unpredictable results?

static someClass *someVar = new someClass( );


If the statement is inside a function, no problem (someVar gets initialized
the first time flow of control passes this line) ...

If it is a global variable, then there are potential problems with order of
initialization:

see http://www.parashift.com/c++-faq-lit...html#faq-10.11 and the next
few questions after it.

David F
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Adam | last post by:
Hi I had Ruby 1.6.8-8 for Windows installed on my WinXP Pro machine prior to installing Python 2.3. After installing Python 2.3, I tried to <----- screen output of python interactive command...
14
by: Pedro Werneck | last post by:
Hi I have a class A, with metaclass M_A, and class B, subclass of A, with metaclass M_B, subclass of M_A. A class C, subclass of B must have M_B or a subclass of it as metaclass, but what if...
0
by: VHR | last post by:
Hi, I apologize for posting this a second time, but no one replied from the other group where I posted it. I have a design master and 4 replicas that I have successfully synced on about 4-5...
14
lotus18
by: lotus18 | last post by:
Hello World I have a problem in detecting the conflict schedule (Day and Time). Day 1. M 2. T 3. W 4. TH 5. F
14
lotus18
by: lotus18 | last post by:
Hello all I have these records on my Day Table for my complete database table please click here 1. M 2. T 3. W 4. TH 5. F 6. S
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.