I am new to c++. Now I am learning header file.
Sales_data.h
#ifndef SALES_DATA_H
#define SALES_DATA_H
#include <string>
struct Sales_data
{
std::string bookNo;
unsigned units_sold = 0;
double revenue = 0.0;
};
#endif
test.cpp
#include <iostream>
using namespace std;
#include "Sales_data.h"
int main(){
Sales_data book = {"zv", 1, 2};
cout << book.bookNo;
}
If i put those two files in the same folder, it works perfectly. But when i put the sales_data.h in a seperate folder like the following structure:
- include
- Sales_data.h
- src
- test.cpp
then i got the following error:
test.cpp:5:10: fatal error: Sales_data.h: No such file or directory
My c_cpp_properties.json under .vscode looks like this.
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\msys64\\mingw64\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
Any advice will be appreciated!