NetBeans C++ demo - Humboldt State...

7
NetBeans C++ Demo p. 1 last modified: 2017-05-02 NetBeans C++ demo download NetBeans -- https://netbeans.org/downloads/ -- I grabbed "full" version, NOT SURE if C/C++ version is enough; Creating a new project File->New Project in the dialog window that appears, under "Categories", select "C/C++" and under "Projects", select "C/C++ Application"

Transcript of NetBeans C++ demo - Humboldt State...

Page 1: NetBeans C++ demo - Humboldt State Universityusers.humboldt.edu/smtuttle/s17cs111/netbeans-c++-demo-2017-05-02.pdf · 02-05-2017 · (note: CAN use NetBeans to *type in* a C++ program

NetBeans C++ Demo p. 1last modified: 2017-05-02

NetBeans C++ demo• download NetBeans -- https://netbeans.org/downloads/ -- I grabbed "full" version, NOT SURE if

C/C++ version is enough;

Creating a new project

• File->New Project

• in the dialog window that appears, under "Categories", select "C/C++"

and under "Projects", select "C/C++ Application"

Page 2: NetBeans C++ demo - Humboldt State Universityusers.humboldt.edu/smtuttle/s17cs111/netbeans-c++-demo-2017-05-02.pdf · 02-05-2017 · (note: CAN use NetBeans to *type in* a C++ program

NetBeans C++ Demo p. 2last modified: 2017-05-02

• ...then click Next>

• trying: Project Name: Hello1

• Project Location: (browsing to s17cs111, netbeans-play)

• LEAVING the rest...

Page 3: NetBeans C++ demo - Humboldt State Universityusers.humboldt.edu/smtuttle/s17cs111/netbeans-c++-demo-2017-05-02.pdf · 02-05-2017 · (note: CAN use NetBeans to *type in* a C++ program

NetBeans C++ Demo p. 3last modified: 2017-05-02

• ...and clicking Finish

Making Hello, World in my new project• clicking on the arrow next to Hello1 (project) if necessay;

• clicking on the arrow next to Source Files

• ...see the main.cpp? They're starting a main function for me!

– ...and for our purposes, I would rather it NOT be named main.cpp;

– right click (or ctrl-click), pick Rename, rename as, say, hello_again.cpp

Page 4: NetBeans C++ demo - Humboldt State Universityusers.humboldt.edu/smtuttle/s17cs111/netbeans-c++-demo-2017-05-02.pdf · 02-05-2017 · (note: CAN use NetBeans to *type in* a C++ program

NetBeans C++ Demo p. 4last modified: 2017-05-02

• double-click on hello_again.cpp to open it in the middle:

• this is not an AWFUL template -- but it doesn't QUITE meet class coding standards (no EXIT_SUCCESS);

– ...we COULD paste the CS 111 main template here...!

Page 5: NetBeans C++ demo - Humboldt State Universityusers.humboldt.edu/smtuttle/s17cs111/netbeans-c++-demo-2017-05-02.pdf · 02-05-2017 · (note: CAN use NetBeans to *type in* a C++ program

NetBeans C++ Demo p. 5last modified: 2017-05-02

• and edit it to output "Hello world, again!" (and save it)

• Run->Compile File? ...seems to work;

...can I now Run->Run Project...? YES!!

Page 6: NetBeans C++ demo - Humboldt State Universityusers.humboldt.edu/smtuttle/s17cs111/netbeans-c++-demo-2017-05-02.pdf · 02-05-2017 · (note: CAN use NetBeans to *type in* a C++ program

NetBeans C++ Demo p. 6last modified: 2017-05-02

A C++ program with two functions (a main and a non-main)• File->New Project

• Categories: C/C++, Projects: C/C++ Application, Next>

• Project Name: NextSoundPlay,

Project Location: s17cs111/111netbeans-play

...what if I UNCLICK Create main file...?

Finish

• Source Files empty -- what if highlight it and File->New File?

– Categories: C++

– File Type: C++ Source File

– Next>

• File Name: next_sound ... can I not type here? does it have to be newfile?!

– Finish?

– can I right-click and rename to next_sound.cpp? Yes (weird!)

– and paste in next_sound.cpp (or template, or type it in, etc!) and save;

• File->New File?

– Categories: C++

– File Type: C++ *Header* File

– aha--- can type in name next_sound, h file

– Next> [nice! #ifndef et al!]

• File->New File?

– Categories: C++

Page 7: NetBeans C++ demo - Humboldt State Universityusers.humboldt.edu/smtuttle/s17cs111/netbeans-c++-demo-2017-05-02.pdf · 02-05-2017 · (note: CAN use NetBeans to *type in* a C++ program

NetBeans C++ Demo p. 7last modified: 2017-05-02

– File Type: C++ Source File

– name...? next_sound_play, cpp?

• Run-> Build Project?

– Run-> Run Project?

– WORKS!!!!!

(note: CAN use NetBeans to *type in* a C++ program in BSS 317 lab, BUT there are C++ compiler issues there!

IF you transfer the resulting .cpp and .h files to nrs-labs, they CAN be compiled there using g++ as usual, though!)