السلام عليكم ..
إخواني لو عرفت كلاس :
class List
{
class Node
{
public:
Student data;
Node *next;
Node () {next = 0;}
Node ( const Student &s , Node *l = 0): data ( s ) , next (l){}
};
Node *head;
Node *set_position(int );
int count;
public:
List () { head = 0 , count = 0;}
bool insert ( int , const Student &);
};وبعد ذلك عرّفت الفنكشن
Node *set_position(int)
بهذه الطريقة
Node* List::set_position(int pos)
يخرج لي الكمبايلر مجموعة من الأخطاء ..
--------------------Configuration: List - Win32 Debug-------------------- Compiling... List.cpp D:\Unevirsty\Csc113\LAB\Home Work's\LAB #5\Q1\List.cpp(3) : error C2143: syntax error : missing ';' before '*' D:\Unevirsty\Csc113\LAB\Home Work's\LAB #5\Q1\List.cpp(3) : error C2501: 'Node' : missing storage-class or type specifiers D:\Unevirsty\Csc113\LAB\Home Work's\LAB #5\Q1\List.cpp(4) : error C2501: 'set_position' : missing storage-class or type specifiers D:\Unevirsty\Csc113\LAB\Home Work's\LAB #5\Q1\List.cpp(4) : error C2556: 'int *__thiscall List::set_position(int)' : overloaded function differs only by return type from 'class List::Node *__thiscall List::set_position(int)' d:\unevirsty\csc113\lab\home work's\lab #5\q1\list.h(23) : see declaration of 'set_position' D:\Unevirsty\Csc113\LAB\Home Work's\LAB #5\Q1\List.cpp(4) : error C2371: 'set_position' : redefinition; different basic types d:\unevirsty\csc113\lab\home work's\lab #5\q1\list.h(23) : see declaration of 'set_position' D:\Unevirsty\Csc113\LAB\Home Work's\LAB #5\Q1\List.cpp(25) : error C2601: 'empty' : local function definitions are illegal D:\Unevirsty\Csc113\LAB\Home Work's\LAB #5\Q1\List.cpp(34) : error C2601: 'size' : local function definitions are illegal D:\Unevirsty\Csc113\LAB\Home Work's\LAB #5\Q1\List.cpp(39) : error C2601: 'insert' : local function definitions are illegal D:\Unevirsty\Csc113\LAB\Home Work's\LAB #5\Q1\List.cpp(73) : error C2601: 'retrieve' : local function definitions are illegal D:\Unevirsty\Csc113\LAB\Home Work's\LAB #5\Q1\List.cpp(99) : fatal error C1004: unexpected end of file found Error executing cl.exe. List.obj - 10 error(s), 0 warning(s)
ما السبب ؟
وما هي الطريقة الصحيحة للإستدعاء ؟