Monday, June 17, 2024

c - How to solve error UNRESOLVED EXTERNAL SYMBOL for static class field

.h
class OverloadedOperator {
public:
	
	string name;
	float price;
 
	static int n;
};
The problem could be in missing static field initialization in .cpp file. Should be:

.cpp
#include "OverloadedOperator.h"

int OverloadedOperator::n = 0;

No comments:

Post a Comment