how to link header files in c++

后端 未结 4 803
时光说笑
时光说笑 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:08

    You need to compile and then link both source (.cpp) files:

    g++ -Wall -pedantic -g -o your_exe a.cpp ex2.cpp
    

提交回复
热议问题