I have a problem accessing a function from a class with a class object in my main function. I am just trying to create an object for a class and use this object to access the function inside this class .cpp file. I keep getting the error message, and I even created the simplest program to test it, and still get the error message.
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
.Cpp class:
#include <iostream> #include "Attack.h" using namespace std; Attack::Attack() { } void Attack::printShiz() { cout << "Test" << endl; }
How can I fix this error? Every time I try to access the printShiz() function in the Attack class using an object in my main function, I get an error message and she does not think that this function exists in this class.
Error:
error: there is no member named printShiz in the Attack class
source share