i have a big problem, and i don't know if i miss some obvious things or what, however i can't find my mistake. I have Class SPN, A and B. I overloaded 2 times operator=. I want to pass A type or B type as parameter.
void SPN::operator=(A*& R)
{
(*R)(*this);
}
void SPN::operator=(B*& R)
{
(*R)(*this);
}
and it doesnt throw any error. But if i try make operator() in class B or A then with parameter SPN like below:
void A::operator()(SPN*& spn)
{
//todo
}
It throws error that SPN doesn't name a type. I can't even create class SPN object in A or B class. Maybe it is not how objective programming works, so i want to get it, why I can't do that.
There are my codes: A.h (B is the same)
#pragma once
#include "SPN.h"
class A
{
public:
SPN temp; <<it throws error: 'SPN' has not been delcared
void operator()(SPN*& spn); <<it throws error: 'SPN' has not been delcared
};
SPN.h
#pragma once
#include "A.h"
#include "B.h"
#include <random>
#include <iostream>
class SPN
{
public:
friend class A;
friend class B;
A* a;
B* b;
void operator=(A*& R);
void operator=(B*& R);
};
To summarize my question is: Why it throws error, that type SPN doesn't name a type (in A and B classes) but for SPN it works fine (in operators)