I have a problem with accessing a function from a class with the class object in my main
function. I am just trying to make the object for the class and use that object to access the function inside that class's .cpp
file. I keep getting an error and I even made the simplest program to test it and I still get an error.
Main:
#include <iostream>
#include "Attack.h"
using namespace std;
int main()
{
Attack attackObj;
attackObj.printShiz();
}
Class header:
#ifndef ATTACK_H
#define ATTACK_H
class Attack
{
public:
Attack();
void printShiz();
protected:
private:
};
#endif // ATTACK_H
Class .cpp:
#include <iostream>
#include "Attack.h"
using namespace std;
Attack::Attack() {
}
void Attack::printShiz() {
cout << "Test" << endl;
}
How do I fix this error? Everytime I try to access the printShiz()
function in the Attack
class by using an object in my main
function, I get an error and it doesn't think this function exists within this class.
Error:
error: 'class Attack' has no member named 'printShiz'