Commit fe908fbd7bc384775458dbc8cf3ba41b7ef1f0d7
1 parent
7960c2dc
Simplified makefile
Showing
2 changed files
with
4 additions
and
54 deletions
examples11/04-vectortmpl/makefile
| 1 | -all: testvector opnew | 1 | +all: testvector |
| 2 | 2 | ||
| 3 | -testvector: testvector.o | ||
| 4 | - g++ -g -Wall $^ -o $@ | ||
| 5 | - | ||
| 6 | -testvector.o: testvector.cpp vector.h | ||
| 7 | - g++ -std=c++17 -g -c -Wall -pedantic $< -o $@ | ||
| 8 | - | ||
| 9 | -opnew: opnew.o | ||
| 10 | - g++ -g -Wall $^ -o $@ | ||
| 11 | - | ||
| 12 | -opnew.o: opnew.cpp | ||
| 13 | - g++ -g -c -Wall -pedantic $< -o $@ | 3 | +testvector: testvector.cpp vector.h |
| 4 | + g++ -std=c++17 -g -Wall -pedantic $< -o $@ | ||
| 14 | 5 | ||
| 15 | .PHONY: clean | 6 | .PHONY: clean |
| 16 | 7 | ||
| 17 | clean: | 8 | clean: |
| 18 | - -rm testvector.o testvector opnew.o opnew | ||
| 19 | \ No newline at end of file | 9 | \ No newline at end of file |
| 10 | + -rm testvector | ||
| 20 | \ No newline at end of file | 11 | \ No newline at end of file |
examples11/04-vectortmpl/opnew.cpp deleted
100644 → 0
| 1 | -#include <iostream> | ||
| 2 | -using namespace std; | ||
| 3 | - | ||
| 4 | -class Object | ||
| 5 | -{ | ||
| 6 | -public: | ||
| 7 | - Object () | ||
| 8 | - { | ||
| 9 | - cout << "Object::Object() called" << endl; | ||
| 10 | - } | ||
| 11 | -}; | ||
| 12 | - | ||
| 13 | -int | ||
| 14 | -main () | ||
| 15 | -{ | ||
| 16 | - Object *p1 = new Object; /* Object::Object() used */ | ||
| 17 | - Object *p2 = new Object (); /* Object::Object() used */ | ||
| 18 | - int *p3 = new int; /* not initialized ! */ | ||
| 19 | - int *p4 = new int (); /* initialized to zero */ | ||
| 20 | - Object *p5 = new Object[7]; /* Object::Object() used 7 times */ | ||
| 21 | - int *p6 = new int[7]; /* not initialized ! */ | ||
| 22 | - int *p7 = new int[7](); /* initialized to zero */ | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - if(*p3) | ||
| 26 | - cout << "*p3 nonzero" <<endl; | ||
| 27 | - if(*p4) | ||
| 28 | - cout << "*p4 nonzero" <<endl; | ||
| 29 | - if(*p6) | ||
| 30 | - cout << "*p6 nonzero" <<endl; | ||
| 31 | - if(*p7) | ||
| 32 | - cout << "*p7 nonzero" <<endl; | ||
| 33 | - | ||
| 34 | - delete p1; | ||
| 35 | - delete p2; | ||
| 36 | - delete p3; | ||
| 37 | - delete p4; | ||
| 38 | - delete[]p5; | ||
| 39 | - delete[]p6; | ||
| 40 | - delete[]p7; | ||
| 41 | -} |