1234567891011
#include <iostream> #include "class.h" int main() { line *ptr = new line(1.0,1.0,1.0,1.0); ptr->showData(); return 0; }
12345678910111213141516171819202122
#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
12345678910111213141516171819202122232425262728
#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() {}
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 ===|