Well, as a first suggestion, have you considered using std::list? It would save you the trouble of implementing your own linked list semantics. Unless you're writing a linked list for the learning experience (which can be valuable), I suggest using:
struct CarPart { int partNumber; std::string partName; double unitPrice; }; std::list<CarPart> ListOfParts;
You'll also notice I'm using std::string for text, which I suggest you use (unless you have a very good reason not to).
To the question at hand: you could declare the constructor for CarPart private, and then declare ListOfParts as a friend class, that's one way. But consider this: what do you gain by disallowing the construction of a car part external to the list of parts? I can't see that you gain anything. In fact, by using friends you introduce unnecessary complexity into the structure of your code - as using the dreaded 'friend' keyword usually does. Anyway, if you did want to use the friend class method, you would write:
class ListOfParts; struct CarPart { friend class ListOfParts; int partNumber; char partName[40]; double unitPrice; CarPart* Next; private: CarPart() { // Do nothing. } };
Which would mean only ListOfparts could call the default constructor for the list CarPart. Let me make this very clear: this is an abhorrent solution because it breaks rules of encapsulation. But, like mutable, friends have a use (and this isn't it).
<forward_list>which should meet all your needs. You can relax and tell your boss you "solved it" and take the weekend off! :-)CarParta nested class, for now, and for learning only, and when you got it to work, you make the actual type a template and use a generic "node" class, which you keep as a nested class.