Original Post
just messin around with linked lists, this code:
gives me these errors :
C:\Windows\Desktop\linkedlists\main.cpp(26) : error C2872: 'ofstream' : ambiguous symbol
C:\Windows\Desktop\linkedlists\main.cpp(35) : error C2872: 'cout' : ambiguous symbol
C:\Windows\Desktop\linkedlists\main.cpp(54) : error C2872: 'cout' : ambiguous symbol
C:\Windows\Desktop\linkedlists\main.cpp(60) : error C2872: 'cout' : ambiguous symbol
C:\Windows\Desktop\linkedlists\main.cpp(72) : error C2872: 'cout' : ambiguous symbol
i dont get it, could someone help me?
[edited by - johnny_blaze93 on August 12, 2002 5:37:33 PM] [/source]
[edited by - johnny_blaze93 on August 12, 2002 5:38:00 PM]
#include <fstream.h>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <conio.h>
using namespace std;
class Element {
public:
Element ();
~Element ();
char *String;
Element *Next_Element;
};
Element::Element () {
String = new char;
}
Element::~Element () {
delete [] String;
}
void main () {
ofstream linkedlist("LinkedList.txt");
char *String_Temp;
String_Temp = new char;
Element *Element_Temp;
Element *First_Element = 0;
Element *Last_Element = 0;
for (;;) {
cout << "Enter a string.\n";
gets (String_Temp);
if (strcmp(String_Temp , "stop") == 0) break;
Element_Temp = new Element;
strcpy (Element_Temp->String , String_Temp);
Element_Temp->Next_Element = 0;
if (Last_Element)
Last_Element->Next_Element = Element_Temp;
else
First_Element = Element_Temp;
Last_Element = Element_Temp;
}
if (First_Element) {
cout << "Now print the whole list!\n";
Element_Temp = First_Element;
do {
cout << Element_Temp->String<<endl;
Element_Temp = Element_Temp->Next_Element;
linkedlist<< Element_Temp->String;
linkedlist<<"\n";
}
while (Element_Temp);
}
cout << "Press any key to continue!\n";
getch();
_flushall();
linkedlist.close();
}