#include <iostream>
using namespace std;
int main()
{
anotherTest test;
test.DisplayText();
cout << "First line of text From main." << endl;
return 0;
};
class anotherTest
{
public:
void anotherTest::DisplayText()
{
cout << "Second line of text from another class." << endl;
}
}
This code works fine. But when I place the second class "anotherTest" into another file (I.E. remove it from classA.cpp to classB.cpp) like this:
ClassA.cpp
#include <iostream>
using namespace std;
int main()
{
anotherTest test = new anotherTest();
test.DisplayText();
cout << "Yep I'm done!" << endl;
return 0;
}
ClassB.cpp
#include <iostream>
using namespace std;
class anotherTest
{
public:
void anotherTest::DisplayText()
{
cout << "Hello Folks Again!" << endl;
}
};
I cannot get it to work correctly. I have no knowledge on how to create classes across multiple files. Maybe someone can enlighten me on how to do this and to get it working properly. I have been reading multiple books at Barnes and Noble trying to find a solution to my problem and also searching online. Maybe I'm just overthinking something? Or maybe I'm lacking a certain concept? I'm not sure. Any help would be appreciated.

New Topic/Question
Reply




MultiQuote








|