Hiii Experts.... can u tell me the problem in my code please??

#include <iostream>
#include <string>

using namespace std;

struct linkedlist
{
linkedlist *nextvalue;
string value;
};

class link
{
private:
linkedlist *firstvalue;
public:
link()
{firstvalue = NULL;}
void add(string val);
void display();
};
void link::add(string val)
{
linkedlist *_new=_new;
_new -> value = val;
_new -> nextvalue = firstvalue;
firstvalue = _new;
}
void link::display()
{
linkedlist *currentval = firstvalue;
while (currentval != NULL)
{
cout << currentval -> value << endl;
currentval = currentval -> nextvalue;
}
}

int main()
{
link l1;
l1.add("My");
l1.add("Name");
l1.add("Is");
l1.add("Taha");
l1.display();
return 0;
}


Code tags would be nice.

The message from compiler that describes the syntax error would be nice.

First line of the body of link::add.
what is the problem in it ?
there is a difference beetween _new and new linkedlist;
indeed....
so what should i do :) ?
Describe what that line should do. Then try to recollect what kind of syntax does such thing.
linkedlist *_new=_new;

you are trying to assign the value of _new to the pointer _new itself.
change that line to :

linkedlist* _new = new linkedlist;
Topic archived. No new replies allowed.