c++Makefile
c++的Makefile和c的Makefile有些不同。
a.cc>b.cc>c.cc对应头文件a.h和b.h
a.h
a.cc
b.h
b.cc
c.cc
Makefile
c++的Makefile用的是g++,而c用的是gcc
a.cc>b.cc>c.cc对应头文件a.h和b.h
a.h
#ifndef A
#define A
const int num = 10;
class human
{
public:
int a;
int arr[num];
void show();
};
#endif
#define A
const int num = 10;
class human
{
public:
int a;
int arr[num];
void show();
};
#endif
#include "a.h"
void human::show()
{
for (int i =0; i arr[i] = i;
}
}
void human::show()
{
for (int i =0; i
}
}
#ifndef B
#define B
#include "a.h"
class man
{
public:
human a;
int display();
};
#endif
#define B
#include "a.h"
class man
{
public:
human a;
int display();
};
#endif
#include "b.h"
int man::display()
{
a.show();
return a.arr[4];
}
int man::display()
{
a.show();
return a.arr[4];
}
#include
#include "b.h"
int main()
{
man b;
std::cout < return 0;
}
#include "b.h"
int main()
{
man b;
std::cout <
}
object &#61; c.o b.o a.o
c:$(object)
g&#43;&#43; -o c $(object)
c.o:c.cc
cc -c c.cc
b.o:b.cc b.h
cc -c b.cc
a.o:a.cc a.h
cc -c a.cc
.PHOINY:clean
clean:
rm c $(object)
c:$(object)
g&#43;&#43; -o c $(object)
c.o:c.cc
cc -c c.cc
b.o:b.cc b.h
cc -c b.cc
a.o:a.cc a.h
cc -c a.cc
.PHOINY:clean
clean:
rm c $(object)