문제

i have a bit of a tricky problem here. I have 3 classes: agent, campaign, and sale - and they all need to include each other, how can i do this without causing a million errors in VS, I've already tried the ifndef guard and pragma once.

도움이 되었습니까?

해결책

This is way more code than I wanted to see.
In essence, as we have said in the comments you have made everything rely on everything else which can never work.
If you introduce a level of indirection, e.g. make an agent remember a sales id, which is an int, you won't need all headers to include all other headers. Is there a chance that an agent might make more than one sale? If you, instead of sale agent_item_sales; you could store them in a vector

std::vector<int> agent_item_sales;

However, you never use this member variable, so perhaps you can just delete it?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top