相对路径表示

1、如果源文件和引用文件在同一个目录(文件夹)里,直接写引用文件名即可

文件1 D:/file/test.cpp

文件2 D:/file/test2.cpp

在文件1中引用文件2:

test2.cpp

2、../表示源文件所在目录(文件夹)的上一级目录(文件夹),../../表示源文件所在目录的上上级目录,以此类推。

文件1 D:/file/test.cpp

文件2 D:/test2.cpp

在文件1中引用文件2:

../test2.cpp

3、引用下级目录的文件,直接写下级目录文件的路径即可。 

扫描二维码关注公众号,回复: 4355749 查看本文章

文件1 D:/file/test.cpp

文件2 D:/file/nextfile/test2.cpp

在文件1中引用文件2:

nextfile/test2.cpp

4、链接到根目录:使用 /

文件1 D:/file/nextfile/test.cpp

文件2 D:/test2.cpp

在文件1中引用文件2:

/test2.cpp

参考:

https://blog.csdn.net/Yeoman92/article/details/52736504

猜你喜欢

转载自blog.csdn.net/qq_28602183/article/details/84619719