Hello, I know there is no SFML in my code but my code was very long so I recreated the problem with a simple program.
What am I doing wrong?
I want to access the String variable that is in a function called MyFunction(); which is in a class called MyClass() but it says String was not declared in this scope.
main.cpp#include <iostream>
#include <string>
#include "myclass.h"
using namespace std;
int main()
{
MyClass MyClassOb;
MyClassOb.MyFunction();
cout << String.size();
return 0;
}
myclass.cpp#include "myclass.h"
#include <iostream>
using namespace std;
MyClass::MyClass()
{
//ctor
}
MyClass::void MyFunction();
{
string String = "hello";
}
myclass.h#ifndef MYCLASS_H
#define MYCLASS_H
class MyClass
{
public:
MyClass();
void MyFunction();
};
#endif // MYCLASS_H