How to share variable in two C++ files

后端 未结 3 1435
温柔的废话
温柔的废话 2021-01-17 06:22

I am trying a code which has two C++ files(client.cpp and server.cpp) and one common.h header file which contais a class and functions

3条回答
  •  梦谈多话
    2021-01-17 07:02

    in one and only one C file write (without extern) at main level (not in function)

    int ch;

    BUT not declare in main, beause the first will be hidden, You can set value

    ch = 1;

    but not declare;

提交回复
热议问题