SLIDE 1
CS ¡162 ¡ Intro ¡to ¡Computer ¡Science ¡II ¡
Separate ¡Compila4on ¡
1 ¡
CS 162 Intro to Computer Science II Separate Compila4on - - PowerPoint PPT Presentation
CS 162 Intro to Computer Science II Separate Compila4on 1 Compila4on #include <iostream> int main() { std::cout << Hello world
1 ¡
2 ¡
3 ¡
4 ¡
5 ¡
#include “functions.hpp” int square(int x) { return x * x; }
int square(int x)
6 ¡
#include “functions.hpp” int main() { std::cout << square(12) << std::endl; return 0; }
7 ¡
G++ program1.cpp functions.cpp –o program1
8 ¡
g++ functions.cpp –c –o functions.o
g++ program1.cpp functions.o –o program1
9 ¡
10 ¡
#ifndef FUNCTIONS_HPP #define FUNCTIONS_HPP int square(int x); #endif
11 ¡
12 ¡