473,569 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why doesn't nothrow work?

This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not C+
+.

I copied a program from http://www.cplusplus.com/doc/tutorial/dynamic.html
(if that's a bad place to go for a tutorial, feel free to direct me
elsewhere), and the following line gets an error:

p= new (nothrow) int[i];

Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
confused by earlier errors, bailing out

It seems odd to me that it's calling 'nothrow' a function; is (XXX)
really valid functional notation in C++? I thought that syntax was
reserved for casts.

I'm using Bloodshed Dev-C++ Version 4, on Microsoft Windows XP Version
5.1.2600. Any ideas as to what my problem might be?

May 29 '07 #1
16 13286
Dustan wrote:
This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not
C+ +.

I copied a program from
http://www.cplusplus.com/doc/tutorial/dynamic.html (if that's a bad
place to go for a tutorial, feel free to direct me elsewhere), and
the following line gets an error:

p= new (nothrow) int[i];
Have you tried

p = new (std::nothrow) int[i];

?
>
Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
confused by earlier errors, bailing out

It seems odd to me that it's calling 'nothrow' a function; is (XXX)
really valid functional notation in C++? I thought that syntax was
reserved for casts.

I'm using Bloodshed Dev-C++ Version 4, on Microsoft Windows XP Version
5.1.2600. Any ideas as to what my problem might be?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 29 '07 #2
On May 29, 12:02 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
Dustan wrote:
This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not
C+ +.
I copied a program from
http://www.cplusplus.com/doc/tutorial/dynamic.html(if that's a bad
place to go for a tutorial, feel free to direct me elsewhere), and
the following line gets an error:
p= new (nothrow) int[i];

Have you tried

p = new (std::nothrow) int[i];

?
Thanks for the response.

Yes I had tried that, and no, it didn't work. I didn't get the exact
same error messages, but it conveyed the same problem:
`::nothrow' undeclared (first use here)
confused by earlier errors, bailing out
Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
confused by earlier errors, bailing out
It seems odd to me that it's calling 'nothrow' a function; is (XXX)
really valid functional notation in C++? I thought that syntax was
reserved for casts.
I'm using Bloodshed Dev-C++ Version 4, on Microsoft Windows XP Version
5.1.2600. Any ideas as to what my problem might be?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

May 29 '07 #3
Dustan wrote:
This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not C+
+.

I copied a program from http://www.cplusplus.com/doc/tutorial/dynamic.html
(if that's a bad place to go for a tutorial, feel free to direct me
elsewhere), and the following line gets an error:

p= new (nothrow) int[i];

Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
confused by earlier errors, bailing out
Did you #include <new>?
May 29 '07 #4
Dustan wrote:
This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not C+
+.
C++ it's a little bit tricky but when you know how to use it it's very
powerful, more than python or java. It's worth the time ;)
I copied a program from http://www.cplusplus.com/doc/tutorial/dynamic.html
(if that's a bad place to go for a tutorial, feel free to direct me
elsewhere), and the following line gets an error:
I don't know exactly, many tutorials in the net have got slight errors
or imperfections.
>
p= new (nothrow) int[i];

Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
confused by earlier errors, bailing out

It seems odd to me that it's calling 'nothrow' a function; is (XXX)
really valid functional notation in C++? I thought that syntax was
reserved for casts.
Well, it's not. The brackets are just dummy, and then ignored, and the
token is interpreted as a function reference. But those are
technicalities for a learner, in my opinion. You will learn, with the
experience, to do this:

1) read the error: `nothrow' undeclared
2) why is undeclared? it's standard library! so, try std::nothrow
3) error: ‘nothrow’ is not a member of ‘std’... Damn!
4) why it is not? because everything in c++ has to be defined somewhere,
and all the things of the standard library are defined in a header file
5) pick a book, and check out std::nothrow
6) #include <memory>
7) it works!

;)

Regards,

Zeppe
May 29 '07 #5
On May 29, 12:46 pm, Zeppe
<zep_p@.remove. all.this.long.c omment.yahoo.it wrote:
Dustan wrote:
This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not C+
+.

C++ it's a little bit tricky but when you know how to use it it's very
powerful, more than python or java. It's worth the time ;)
Yeah... they say that exact same thing over at c.l.python and
c.l.java. I get the feeling everyone's biased or something. ;)
I copied a program fromhttp://www.cplusplus.c om/doc/tutorial/dynamic.html
(if that's a bad place to go for a tutorial, feel free to direct me
elsewhere), and the following line gets an error:

I don't know exactly, many tutorials in the net have got slight errors
or imperfections.
p= new (nothrow) int[i];
Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
confused by earlier errors, bailing out
It seems odd to me that it's calling 'nothrow' a function; is (XXX)
really valid functional notation in C++? I thought that syntax was
reserved for casts.

Well, it's not. The brackets are just dummy, and then ignored, and the
token is interpreted as a function reference. But those are
technicalities for a learner, in my opinion. You will learn, with the
experience, to do this:

1) read the error: `nothrow' undeclared
2) why is undeclared? it's standard library! so, try std::nothrow
3) error: 'nothrow' is not a member of 'std'... Damn!
4) why it is not? because everything in c++ has to be defined somewhere,
and all the things of the standard library are defined in a header file
5) pick a book, and check out std::nothrow
6) #include <memory>
7) it works!

;)

Regards,

Zeppe
Thanks to red floyd and Zeppe for their responses. Both <newand
<memoryworked , which I must admit is only further confusing for me;
I guess I still have quite a ways to go.

May 29 '07 #6
Dustan wrote:
[..]
Thanks to red floyd and Zeppe for their responses. Both <newand
<memoryworked , which I must admit is only further confusing for me;
Why is it confusing you? 'nothrow' is a symbol. It needs to be
defined; and it is, in <new>. It is conceivable that <newis
included into <memory(althoug h it doesn't have to be), so when
you include <memory>, you also implicitly include <new(which is
what you actually need for 'nothrow').

It's similar to how 'NULL' is defined pretty much any time you pull
in *any* standard header (probably), while its actual residence is
in <cstddef>, <cstring>, <cstdio>, <ctime>, or <cwchar>. Don't
rely on NULL's definition to exist all the time, do include one of
the required headers for it.
I guess I still have quite a ways to go.
Most of us do, as well.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 29 '07 #7
Dustan wrote:
On May 29, 12:46 pm, Zeppe
<zep_p@.remove. all.this.long.c omment.yahoo.it wrote:
>Dustan wrote:
>>This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not C+
+.
C++ it's a little bit tricky but when you know how to use it it's very
powerful, more than python or java. It's worth the time ;)

Yeah... they say that exact same thing over at c.l.python and
c.l.java. I get the feeling everyone's biased or something. ;)
>>I copied a program fromhttp://www.cplusplus.c om/doc/tutorial/dynamic.html
(if that's a bad place to go for a tutorial, feel free to direct me
elsewhere), and the following line gets an error:
I don't know exactly, many tutorials in the net have got slight errors
or imperfections.
>> p= new (nothrow) int[i];
Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
confused by earlier errors, bailing out
It seems odd to me that it's calling 'nothrow' a function; is (XXX)
really valid functional notation in C++? I thought that syntax was
reserved for casts.
Well, it's not. The brackets are just dummy, and then ignored, and the
token is interpreted as a function reference. But those are
technicaliti es for a learner, in my opinion. You will learn, with the
experience, to do this:

1) read the error: `nothrow' undeclared
2) why is undeclared? it's standard library! so, try std::nothrow
3) error: 'nothrow' is not a member of 'std'... Damn!
4) why it is not? because everything in c++ has to be defined somewhere,
and all the things of the standard library are defined in a header file
5) pick a book, and check out std::nothrow
6) #include <memory>
7) it works!

;)

Regards,

Zeppe

Thanks to red floyd and Zeppe for their responses. Both <newand
<memoryworked , which I must admit is only further confusing for me;
I guess I still have quite a ways to go.
#include <memoryworkin g is mere coincidence. Your implementation' s
version of <memoryreferenc es <new>. Per the Standard 20.4, <memory>
does not define nothrow. It's defined in <newper 18.4/1.
May 29 '07 #8
red floyd wrote:
Dustan wrote:
>Thanks to red floyd and Zeppe for their responses. Both <newand
<memoryworke d, which I must admit is only further confusing for me;
I guess I still have quite a ways to go.

#include <memoryworkin g is mere coincidence. Your implementation' s
version of <memoryreferenc es <new>. Per the Standard 20.4, <memory>
does not define nothrow. It's defined in <newper 18.4/1.


Citing the standard, I guess, is to simplify the things to the beginner,
isn't it? Anyway, you caught me, I didn't really checked up in the book ^^

Regards,

Zeppe
May 29 '07 #9
Zeppe wrote:
red floyd wrote:
>Dustan wrote:
>>Thanks to red floyd and Zeppe for their responses. Both <newand
<memoryworked , which I must admit is only further confusing for me;
I guess I still have quite a ways to go.

#include <memoryworkin g is mere coincidence. Your implementation' s
version of <memoryreferenc es <new>. Per the Standard 20.4, <memory>
does not define nothrow. It's defined in <newper 18.4/1.

Citing the standard, I guess, is to simplify the things to the beginner,
isn't it? Anyway, you caught me, I didn't really checked up in the book ^^
No, it's more to explain *why* #include <memoryis the wrong answer.
When in doubt, "because the Standard says so", is a good answer.
May 30 '07 #10

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

Similar topics

6
7196
by: Chewy509 | last post by:
Hi Everyone, I'll just start, and say I am not a PHP developer (I'm a sysadmin, who has gotten lumped with a non-working website). But since I like to do this type of stuff, I though I might just learn WTF is going on? :) Basically, sessions are being created, but no info in being stored in the session, and if data is stored (about 1 in...
4
3837
by: Chris Lount | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I'm pretty new to c++ . I'm trying to work out why the following code doesn't work. I've just learned about cin.get() and written the following program to enter a string and store it in an array. When I run the program it asks for the first string and then prints it. However, it doesn't...
3
9633
by: OM | last post by:
Why doesn't a onmouseover function work in a function? (It's prob due to my code being wrong more than anything else!) I've got the following code (snippet): <!-- Begin var image0 = new Image(); image0.src = "blank.jpg"; var image1 = new Image(); image1.src = "map.jpg"; // End -->
6
421
by: JustSomeGuy | last post by:
unsigned short x; ifstream cin; // opened in binary mode. cin >> x; // Doesn't work. yet cin.read((char *) &x, sizeof(x)); works...
3
1671
by: Iver Erling Årva | last post by:
Can anyone please tell me why this doesn't work? The sign changes when I hit the button, and I get no error messages, but the textarea doesn't disappear/reappear. <html> <head> <title>New Page 1</title> </head>
10
1547
by: Brett | last post by:
This code is supposed to work in Netscape 4+ and IE 4+. It works fine in IE but in Netscape 7.2, I get a blank page. Any suggestions? Thanks, Brett <html> <head>
3
5935
by: MeNotHome | last post by:
I am trying to automate web browser navigation and form fill out in vb.net Why doesn't this work? AxWebBrowser1.Document.Forms(0).All("action-download").click() I also tried AxWebBrowser1.Document.Forms(0).All.item("action-download").click() "action-download" is the name of a submit button
3
2722
by: Joey | last post by:
I am working on an asp.net 1.1 web app in C#. I downloaded some sample code that is supposed to allow for me to persist session state. The code is as follows: private void PersistSessionState() { int MilliSecondsTimeOut = (this.Session.Timeout * 60000) - 30000; string Script = @" <script type='text/javascript'> var Count=0;
7
6199
by: yawnmoth | last post by:
http://www.frostjedi.com/terra/scripts/demo/xml.html The first alert() shows the XML that the server is returning. The second alert() shows a particular elements nodeValue and, as you can see, outputs "null". The third alert() shows a particular elements textContent. Atleast in Firefox. In Internet Explorer it returns "undefined". ...
0
7612
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...
0
8122
jinu1996
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...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7970
tracyyun
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...
0
5219
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...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
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...

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.