Docsity

Creating and Compiling a C++ Program: Visual C++ and g++, Study notes of Computer Science

Partial preview of the text

Download Creating and Compiling a C++ Program: Visual C++ and g++ and more Study notes Computer Science in PDF only on Docsity!

Coordinator: Feiqi Su

Discussion Section Notes

Using Visual C++

1. Creating a New Project Choose File, New

Coordinator: Feiqi Su

2. Create Your Own Class File (.cpp)* Choose File, New

Coordinator: Feiqi Su

Compiling Multiple-file Programs

1. Create Files Add a header file 2. Building All

Coordinator: Feiqi Su

Using g++

¾ g++ grossSalary.cpp –o grossSalary ¾ ./grossSalary ¾ man g++

Compiling Multiple-file Programs

Simply list all the source files, don’t include any .h files. Suppose you have grossSalary.cpp and grossSalary.h which is included by grossSalary.cpp ¾ g++ grossSalary.cpp –o grossSalary ¾ ./grossSalary

[from g++ manual page] DESCRIPTION g++ is a script to call gcc with options to recognize C++. C++ source files use one of the suffixes .C',.cc', .cxx',.cpp', or .c++'; preprocessed C++ files use the suffix.ii'.

Other references

There are many tutorials on Visual C++ and g++. For example:

VC: http://elvis.rowan.edu/~kay/cpp/vc6_tutorial/ G++: http://www.cs.wm.edu/cspages/computing/tutorial/gpp.html