// linked list.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include "phone.h"
#include "list.h"
using namespace std;
int main()
{
char last[15],first[15];
long num;
list *ll=new list("Lenon","Jenon",456641);
phone *ph1=new phone("Haim","Moshe",345765),*ph2=new phone("Rabin","itzhak",467323),*phone_ptr;
ll->insert(ph1);
ll->insert(ph2);
ll->print();
ll->del("Haim");
cout<<"AFTER DELETING\N";
ll->print();
cout<<"input last name first name phone number\n";
do
{
cin>>last>>first>>num;
phone_ptr=new phone(last,first,num);
ll->insert(phone_ptr);
}
while(num);
ll->print();
delete ll;
cin.get();
return 0;
}
and visual studio writes me:
1>------ Build started: Project: LinkedList, Configuration: Debug Win32 ------
1> phone.cpp
1>c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\phone.cpp(1): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\phone.cpp(2): warning C4627: '#include "phone.h"': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\phone.cpp(3): warning C4627: '#include <string>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\phone.cpp(4): warning C4627: '#include <process.h>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\phone.cpp(5): warning C4627: '#include <iomanip>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\phone.cpp(38): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
1> list.cpp
1>c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\list.cpp(1): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\list.cpp(2): warning C4627: '#include <string>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\list.cpp(3): warning C4627: '#include "phone.h"': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\list.cpp(4): warning C4627: '#include "list.h"': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\list.cpp(86): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
1> LinkedList.cpp
1>c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\phone.h(1): error C2011: 'phone' : 'class' type redefinition
1> c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\phone.h(1) : see declaration of 'phone'
1>c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\linkedlist.cpp(14): error C2027: use of undefined type 'phone'
1> c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\phone.h(1) : see declaration of 'phone'
1>c:\users\alex\documents\visual studio 2010\projects\linkedlist\linkedlist\linkedlist.cpp(14): fatal error C1903: unable to recover from previous error(s); stopping compilation
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Is that the link you're using? That book appears really dated. It's using features that are no longer supported, but here is where it shows how to implement a linked list. http://newdata.box.sk/bx/c/htm/ch11.htm#Heading47
I just added 3 phone numbers to the linked list. I can easily remove items also. All of that code you have is in this little program, with the exception that it works, compiles, it's standard (it must compile on every single ANSI C++ compiler out there) and is written by industry professionals.
Bookmarks