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;

this is for sally.cpp

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


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

this is for sally.h

#ifndef SALLY_H
#define SALLY_H

class sally
    void tim();


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


- page 1
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
0 Bernard Pyc0d333 Parah · December 12, 2014
did it work? you can also thank people by giving them a vote by clicking on the vote button.
But more importantly happy to always help.
0 Teemmy Ellorry · December 12, 2014
You guys are sweet Thanks a ton @ all... am more than grateful...8-)
0 Teemmy Ellorry · December 12, 2014
Will do just that now... I'll get back to you guys soon...
+1 Bernard Pyc0d333 Parah · December 11, 2014
Teemmy sorry was in class.
Since you are using Dev, you can still create a project in Dev.

1.On the main menu, click File -> New Project...
2.On the New Project dialog box, click the Project property sheet if necessary.
3.Click Console Application
4.Click OK.
5.On the subsequent New Project dialog box, type the name of the project
6.Click OK. You will be asked to create a location for the project.
7.Give the project folder a name the folder
 The first c++ program has been created for you(main.cpp)
9.then you can create new classes in the folder 
+1 Mathias Frits Rørvik · December 11, 2014
Don't use DevC++ or CodeBlocks. People have trouble with these all the time, since you're on windows use Visual Studio.

Good luck!
0 Teemmy Ellorry · December 11, 2014
Someone please rescue me... Have been coding all day trying to figure this out, have tried all what you guys said... its still giving errors... is it because of the compiler am using? "DEVc" I created all files manually unlike "codeblocks" which builds the two files when creating a class. PLEASE HELP!!!
0 Teemmy Ellorry · December 11, 2014
I created all files inside a folder.
0 Teemmy Ellorry · December 11, 2014
Am not using "Codeblocks" am using "Devc"
  • 1
  • 2



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

Bucky Roberts Administrator