Help me figure out my mistake please(classes in separate files)

+1 Teemmy Ellorry · December 11, 2014
This is for main.cpp

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

int main()
{
  sally sallyob;
  sallyob.tim();
}

this is for sally.cpp

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

sally::sally()
{
}

void sally::tim()
{
    cout<<"I love programming"<<endl;
}

this is for sally.h

#ifndef SALLY_H
#define SALLY_H

class sally
{
    public:
        sally();
    void tim();
    protected:
    private:
};

#endif

These are the errors its giving me when i compile and run:
7        F:\WorkShop\C++ Programming\PracticeSpace.cpp    undefined reference to `sally::sally()'
8        F:\WorkShop\C++ Programming\PracticeSpace.cpp    undefined reference to `sally::tim()'
          F:\WorkShop\C++ Programming\collect2.exe    [Error] ld returned 1 exit status

Post a Reply

Replies

- page 2
Oldest  Newest  Rating
0 Bernard Pyc0d333 Parah · December 12, 2014
yea justin,another solution
-1 justin zodkoy · December 12, 2014
I use code blocks and I just needed to restart my IDE
  • 1
  • 2

C++

106,956 followers
About

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

Links
Moderators
Bucky Roberts Administrator