Ho il seguente cod:
codice:
// Screen.h
#ifndef SCREEN_H
#define SCREEN_H
class Screen
{
public:
Screen(int x, int y);
~Screen();
inline int cursor() const { return _cursor; }
private:
int _cursor,_x,_y;
};
#endif
codice:
// Screen.cpp
#include "Screen.h"
Screen::Screen(int x, int y): x(_x), y(_y)
{
_cursor = x/y;
}
Screen::~Screen()
{
delete _x, _y, _cursor;
}
codice:
// Test.cpp
#include <cstdio>
#include <iostream>
#include "Screen.h"
using namespace std;
int main()
{
int i=5, j=10;
Screen *ptrSc = new Screen(i, j);
cout << ptrSc->cursor() <<endl;
system("PAUSE");
return 0;
}
Ma mi da:
Compilatore: C++ Optimized Maximum
Esecuzione di g++.exe...
g++.exe "C:\Documents and Settings\Admin\Desktop\Screen\Test.cpp" -o "C:\Documents and Settings\Admin\Desktop\Screen\Test.exe" -fexpensive-optimizations -O2 -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:\DOCUME~1\Admin\IMPOST~1\Temp/ccY5aaaa.o(.text+0x39):Test.cpp: undefined reference to `Screen::Screen(int, int)'
Esecuzione terminata