Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
main.cpp
C++
#include <iostream>
#include "Sally.h"
using namespace std;

int main()
{

   Sally sallyObject;

   sallyObject.printCrap();

    return 0;
}

Sally.h
C++
#ifndef SALLY_H
#define SALLY_H

class Sally
{
    public:
        Sally();
        void printCrap();
    protected:
    private:
};

#endif // SALLY_H

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

Sally::Sally()
{
}

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

ERROR message looks like this:
'class Sally' has no member named 'printCrap'|
Posted
Updated 7-Dec-14 3:23am
v2
Comments
CHill60 7-Dec-14 9:45am    
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
Richard MacCutchan 7-Dec-14 12:54pm    
Worked for me as it stands.
Laurisplus 8-Dec-14 5:50am    
Hi! Please, tell me how can I do these things you mentioned - put $(ProjectPath) into project, properties, VC++ Directories, Include Directories?
Also - why should I change Sally.cpp to #include "stdafx.h"?
Legor 10-Dec-14 4:47am    
This comment is very Visual Studio specific. You will not need to use stadafx.h which is for precompiled headers created with the VS compiler. Dont get confused by the comment of Chill60. Your example is very basic and should work just fine as it is.

What IDE / Compiler are you using?
Laurisplus 10-Dec-14 14:25pm    
I'm using CodeBlocks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900