im curious as to if there is a benefit to the coder and/or reader in assigning a variable name in a class functions prototype...for example


class book {

private:

//blah

public:

book( int, string, double);

}

vs.

class book {

private:

//blah

public:

book( int data1, string name1, double data2);

}

which is usually preffered and why?

which is usually preffered and why?

Both book::book( int, string, double); and book::book( int data1, string name1, double data2); are indicative of poor programming style; one could argue that the second version is the worse one because it introduces meaningless noise words.

Well written code is self-documenting; the basic idea is to make source code easier to read and easier to understand.

Something like book::book( int num_pages, const std::string& author, double price); where formal parameter names convey meaning is generally preferred.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.