Class "has no member named" error

+1 Lauris Krolis · December 7, 2014
I'm following instructions in video But there is some error.


#include <iostream>
#include "Sally.h"
using namespace std;

int main()

   Sally sallyObject;


    return 0;


#ifndef SALLY_H
#define SALLY_H

class Sally
        void printCrap();

#endif // SALLY_H


#include "Sally.h"
#include <iostream>
using namespace std;


void Sally::printCrap(){
cout << "Did someone say steak?" << endl;

ERROR message looks like this:
'class Sally' has no member named 'printCrap'|

Post a Reply


Oldest  Newest  Rating
+2 Todd Gee · October 16, 2015
Just for future searches, had the same problem.  I also created the class under file, new, class, but unchecking use relative path seemed to fix my problem the second time around.  I also copied and pasted my original code in the new file, so it wasn't a typo.
0 Bernard Pyc0d333 Parah · December 8, 2014
hello laura.
My bet is that the solution  you found on that forum  is for Visual C++ (VC++).
I am 95% positive that if you follow these steps am gonna give you, I believe that your problem will be solved.

1. Create a new project  ( remember not a file)..when you  create a project, a main.cpp file will be in it automatically.
That is the first one that appears on the screen.

2. click on open

3. Navigate to the project and open the main.cpp file which you will find under a folder called sources.

From there you can just follow the video.
 look at the tab by the left of the screen, you will see that Bucky's works are in a project called  WATERMELON
Do that before we will be sure if it is a Codeblocks configuration error because from the error you are having it doesn't seem like your compiler is having any problem.
0 Lauris Krolis · December 8, 2014
Hi, Bernard! It seems I have done everything like in Bucky's video. My guess is - I have something wrong with CodeBlocks configuration. In another forum someone replied to me about my qustion with this information:
"This worked for me after I put $(ProjectPath) into project, properties, VC++ Directories, Include Directories and after I changed Sally.cpp to #include "stdafx.h" and put Sally.h after iostream"
How can I put $(ProjectPath) into project, properties, VC++ Directories, Include Directories?
0 Bernard Pyc0d333 Parah · December 8, 2014
hello Laura, the code is correct. You just need to create a project first, then give it a name a directory.
you will get an empty environment
Then go to the project folder and open the main.cpp file.
After that you can create your classes as Bucky did in the video and you are good to go.

Let me know if it works. :)
  • 1



Used in many types of software including music players, video games, and many large scale applications.

Bucky Roberts Administrator