undefined reference to class constructor

Hello, i have wrote some code
main.cpp
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include "class.h"


int main()
{
line *ptr = new line(1.0,1.0,1.0,1.0);
ptr->showData();
return 0;
}

class.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef CLASS_H_INCLUDED
#define CLASS_H_INCLUDED
#include <string>

using namespace std;

class line
{
        protected:
            double x1;  
            double y1;
            double x2; 
            double y2;
            double width;   
            string color;   
            string style;   
        public:
        line(double , double ,double , double ); 
        ~line();
        void showData(); 
};
#endif // CLASS_H_INCLUDED 

class.cpp
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
#include "class.h"
#include <string>

line::line(double valuex1, double valuey1,double valuex2, double valuey2)
{
    x1=valuex1;
    y1=valuey1;
    x2=valuex2;
    y2=valuey2;
    width=1.0;
    color="black";
    style="line";
};


void line::showData()
{
        cout<<"First point: ( "<<x1<<" , "<<y1<<" )";
        cout<<" Second point: ( "<<x1<<" , "<<y1<<" )"<<endl;
        cout<<width<<endl<<color<<endl<<style<<endl;

};
line::~line() {}





but when i compile that he say

obj/Debug/main.o||In function `main':|
~/Desktop/workbench/2dTextEditor/main.cpp|7|undefined reference to `line::line(double, double, double, double)'|
~/Desktop/workbench/2dTextEditor/main.cpp|8|undefined reference to `line::showData()'|
||=== Build finished: 2 errors, 0 warnings ===|


I tried find information on internet, but can't.
And when i put this code in main.cpp he is working
Thx
maybe i have some problem with english, but if i understand your post right... i gave all code
@Lupet: Don't derail threads, please.

@Toctep: Are you linking main.cpp and class.cpp?
You mean #include "class.h" in main.cpp
or if not, i think i need read about what mean linking
i think i need read about what mean linking

Exactly.
i think i have another problem/
In a book about c++ in main.cpp author use #include "className.h"
I change class.h to class.cpp and program start compile and work
So why i can use class.h like in book?
Because you still didn't look up what linking is.
I found something but there is not enough info.
Can you help with what kind of info i must search?
thx
Topic archived. No new replies allowed.