When it comes to information hiding does one use include.h or include.cpp in the main func?

I finally see the benefit of information hiding so I am trying to learn it. I have the header class, implementation class, and the main function setup correctly but when I include a ".h" header file as my book and Bucky [youtube] implies, I get an error.

This is the error in the main function
C:\Users\D Taqee\Desktop\C++\Dummy Folder - All Practice Exercises\Dummy Code\addemup learning to hide info.o:addemup learning to hide info.cpp|| undefined reference to `addemup::addemup()'|


This is the error in the implementation file
C:\SDL Library\SDL - 1.2.15\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_main'|
||=== Build finished: 1 errors, 0 warnings ===|


And my header file won't even compile because it is looking for an .exe file that does not exist.

BUT, when I include the ".cpp" file instead of the ".h" file the program runs just fine. Can someone please explain what is happening and how can I include the .h file as it should be. Thanks.

Main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <string>
#include "addemup.h"
using namespace std;

int main()
{
    addemup math;
    int f, s;

    cout << "Enter 2 numbers to add and multiply"<<endl<<endl;
    cout<<"First number: ";
    cin>>f;

    cout<<"Second Number: ";
    cin>>s;
    cout<<endl<<endl;

    cout<<"The numbers added together are "<<math.addition(f,s)<<endl;
    cout<<"The number subtracted from each other are "<<math.subtraction(f,s)<<endl;

    return 0;
}


Header File
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef ADDEMUP_H
#define ADDEMUP_H


class addemup
{
    public:
        addemup();

        int addition(int, int);

        int subtraction(int, int);
};

#endif // ADDEMUP_H 


Implementation File
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <string>
#include "addemup.h"
using namespace std;


addemup::addemup()
{
    cout<<"yeehaw"<<endl;
}

int addemup::addition(int a, int b)
{
    return a + b;
}

int addemup::subtraction(int a, int b)
{
    return a - b;
}


Why are linking the sdl.a file?
I need to link to that to program games with sdl. Do I need to link to the folder my .exe resides for this to work?..will try now
I found my problem. I was compiling from a cpp file instead of compiling from the project file. Thanks.
Topic archived. No new replies allowed.