how to link header files in c++

后端 未结 4 806
时光说笑
时光说笑 2021-02-04 15:27

I\'m new to programming in C++ with header files. This is my current code:

//a.h
#ifndef a_H
#define a_H
namespace hello
{
  class A
  {
    int a;
    public:
          


        
4条回答
  •  离开以前
    2021-02-04 16:24

    You need to compile and link both source files, e.g.:

    g++ ex2.cpp a.cpp -o my_program
    

提交回复
热议问题