Moises Rojo Moises Rojo - 11 days ago 5
C++ Question

"Separating the Interface from the Implementation" C++ Deitel 9e Book (How to compile?)

fig03_13.cpp file from Deitel's Book C++ 9e does not compile.

$ g++ fig03_13.cpp
/tmp/cckud0qb.o: In function `main':
fig03_13.cpp:(.text+0x4b): undefined reference to `GradeBook::GradeBook(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
fig03_13.cpp:(.text+0xa0): undefined reference to `GradeBook::GradeBook(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
fig03_13.cpp:(.text+0xce): undefined reference to `GradeBook::getCourseName[abi:cxx11]() const'
fig03_13.cpp:(.text+0xe4): undefined reference to `GradeBook::getCourseName[abi:cxx11]() const'
collect2: error: ld returned 1 exit status

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/6.2.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --disable-libgcj --with-isl --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 6.2.1 20160916 (Red Hat 6.2.1-2) (GCC)


https://gitlab.com/moisesroj0/deitel/tree/master/C++%209e/Code_Examples/ch03/fig03_11_13

Answer

At least you need:

g++ GradeBook.cpp fig03_13.cpp
Comments