An electromagnet consists of: