i have code:
main.cpp
#include <iostream>
#include "add.h"
#include "var.h"
using namespace std;
int main() {
std::cout << width << height << std::endl;
show();
return 0;
}
add.cpp
#include <iostream>
#include "add.h"
#include "var.h"
int add(int x, int y) {
return x + y;
}
int show() {
std::cout << width << height << std::endl;
return 0;
}
add.h
#pragma once
int add(int x, int y);
int show();
var.cpp
#include "var.h"
int width = 1024, height = 768;
var.h
#pragma once
int width, height;
i need to include var.h in main.cpp and add.cpp to use variables in those files, but when i start compiling my program, i get an error: C2086 int width redefinition file var.cpp line 3, C2086 int height redefinition file var.cpp line 3
externinlinesince C++17.std::endldoes. Use'\n'to end a line unless you have a good reason not to.