I am new to c++ programming and know the basics of c++. I am trying to link three files, but i am unable to get the output.I am studying the book c++ cookbook right now
Suppose we have the files a.hpp a.cpp, b.hpp b.cpp,c.hpp c.cpp with the following code:
a.hpp
#ifndef A_HPP_INCLUDED
#define A_HPP_INCLUDED
void a();
#endif
a.cpp
#include "a.hpp"
#include <iostream>
void a()
{
std::cout<<"a \n ";
}
b.hpp
#ifndef B_HPP_INCLUDED
#define B_HPP_INCLUDED
void b();
#endif
b.cpp
#include "b.hpp"
#include <iostream>
void b()
{
std::cout<<"b \n ";
}
c.hpp
#ifndef C_HPP_INCLUDED
#define C_HPP_INCLUDED
void c();
#endif
c.cpp
#include "a.hpp"
#include "b.hpp"
#include "c.hpp"
void c()
{
a();
b();
}
int main()
{
c();
return 0;
}
I have created all the files in one folder and commands i used to compile and link them are
$:g++ -c -Wall a.cpp b.cpp c.cpp
$:g++ -o -Wall a.o b.o c.o
$:./a.out
I was expecting the outout
a
b
but there was no output at all.Request you all to help me out with this.