undefined reference error. Any idea ?

I have this code at myclass.cpp
#include "Wfile.h"
string file_path="c:\\afile.txt";
WFileUtiles wfileutils;
tam_file= wfileutils.sizefichero(file_path);

At compile time i get :
undefined reference to `WFileUtiles::WFileUtiles()'

I dont understad this 'undefined reference' , please help


this is "Wfile.h"

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
#ifndef WFILE_H
#define WFILE_H
#include <string> 
#include <fstream>
#include <iostream>

using namespace std;

    class WFileUtiles {

    public:
       WFileUtiles ();
       ~WFileUtiles();
       long sizefichero(string);
    };

    long WFileUtiles::sizefichero (string path) {
        ifstream file(path.c_str(),ios::in);
        file.seekg(ios::end);
        
        long size= file.tellg();
        file.close();        
        return size;
    }



#endif // WFILE_H 
Your missing the body of your default constructor and destructor.

One solution (assuming you don't want either to do anything)

Change
1
2
WFileUtiles ();
~WFileUtiles ();

to
1
2
WFileUtiles() {}
~WFileUtiles() {}
Oh my god !!
I'm ....
Thanks binarybob to answer this stupid question
Topic archived. No new replies allowed.