LNK2019 error

closed account (GL1Rko23)
Now I know what this error means but I am having the strangest problem with it and someone else on here might have had it before and can see what I can not.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 //Counting_Observer.h
     
    #ifndef COUNTING_OBSERVER_H
    #define COUNTING_OBSERVER_H
     
    #include "observer.h"
    #include "observable.h"
    #include "monitor.h"
    #include <iostream>
     
    class CountingObserver : public Observer
    {
    public:
            CountingObserver(Observable* subject);
			//CountingObserver();
            void update(Observable* subject);
            void show_data();
    private:
            char observer_state;
    };
     
     
    #endif 


With the default constructor commented out it calls for the default constructor, but when i implement it, it then has linker errors.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "monitor.h"
#include "counting_observer.h"
#include "accumulating_observer.h"
#include <iostream>
using namespace std;
//==============================================================================
void process_input(char chr);

//==============================================================================
int main()
{
    // Monitor for uppercase chars
    UpperCaseMonitor     uc_monitor;
    
    // Want to be notified when there's an upper case char
    CountingObserver     observer1;
    AccumulatingObserver observer2;

    // Get registered
    uc_monitor.attach(&observer1);
    uc_monitor.attach(&observer2);

    // Prompt
    cout << "Enter some text, type ^d when done.\n";

    // Process text
    char chr;
    while (cin.get(chr))
    {
        uc_monitor.watch(chr);
        process_input(chr);
    }

    // See what observers know
    observer1.show_data();
    observer2.show_data();

	
}


Any ideas?
I don't remember exactly what LNK2019 is, but if it's "unresolved external symbol" that means you never gave the function a body.
Linker errors mean that the linker cannot find a function definition.

This might be because you have not written the code for a function, or haven't linked a necessary library.

It can also happen if a file wasn't compiled, because it wasn't in the list of files for the project - so make misses out on that file.

If you post the full output (always do this), then we might be able to tell which is the offending function.

HTH
closed account (GL1Rko23)
Thanks for your help guys, what I had done was defined one of the functions in the wrong header
Topic archived. No new replies allowed.