Iteratable single linked list of floats.

Alain De Vos devosalain at ymail.com
Wed Apr 21 13:19:46 UTC 2021


Formatted ,
```
import std.stdio;
void main(){
	struct List {
		struct Node {
			float f;
			Node *next;
			}
		Node * root=null;
		bool empty() const {return !root;}
		void popFront() {root=root.next;}
		float front() const {return root.f;}
		void push(float f) {
				Node * newnode=new Node();
				newnode.f=f;
				root.next=newnode; // Segmentation fault
				}
	}
	List * l=new List();
	l.push(3);
	foreach(element;l){ // Invalid foreach aggregate
	  writeln(element.root.f);
	}
}
```


More information about the Digitalmars-d-learn mailing list