I had made 2 class in my project. I want to use a function from 1st class to the 2nd class the problem is I can't instantiate the 1st class to the 2nd class. By the way both classes were declared in different headers.
here is a sample code:
header 1:
class 1stclass{
public:
2ndclass *class2;
void function1(QString parameter1)
{
QString str1;
list = class2->function2(parameter1);
}
};
header 2:
class 2ndclass{
public:
QString function2(QString parameter2)
{
QString str2 = parameter2 + "hello";
return str2;
}
};
I want to use the function in function 2 but it gives me an error. here is the error message:
- ISO C++ forbids declaration of '2ndclass' with no type;
- expected ';' before '*' token;
- 'class2' was not declared in this scope;
header
file for2ndclass
into header file for1stclass
? – beduin1stclass
(i.e. at the top)? – mlvljr