Question Class Constructors, Setters, and Getters.

Pages: 12
closed account (Ezyq4iN6)
@Cubbi
Thanks for the reading links.

I read over the link you sent in regards to the interface design,
but I'm not sure I fully understand how to change it to meet with
those standards. Is it simply that the variable names that should
be more descriptive of their unit type like the following code?

1
2
3
4
5
6
Vehicle(double length_in_meters,
        double width_in_meters,
	double x_coordinate,
        double y_coordinate,
        double speed_in_m_per_s,
        double angle_in_degrees)


I changed 'void report();' to 'const void report();'. That's the
only change you meant for that, correct?

@jonnin
Thanks jonnin, that clears things up a bit.

@TheIdeasMan
I haven't seen relationships listed like that before, but it does seem to make some sense. I have only seen a minimal amount of programming flowcharts, so I would assume I will see more of these three as I get more experience.

The proper use of namespace often eludes me, as most of the examples I look at don't use one, though I suppose that is because most of them are short pieces of code when compared to a large piece of software. It's good to at least know there is a way to condense nested ones with an alias.
It's good to at least know there is a way to condense nested ones with an alias.


One can use them for a single namespace too:

1
2
3
namespace TheIdeasMan {};

namespace tim = TheIdeasMan;


I do that because I like to have only 3 chars for an alias:

tim::myvar

I changed 'void report();' to 'const void report();'. That's the
only change you meant for that, correct?


It should be :

void report() const ;

Here the const means that none of the member variables can change value. The compiler enforces this.
closed account (Ezyq4iN6)
The 3 character idea sounds like a good rule to use. I'll have to read up more on namespaces, because until I posted my question, "using namespace std" was pretty much all I knew about them.

Thanks for correcting my function. I figured const in the front seemed weird, since I guess it would return a constant value (not sure how that would work unless it was only for initializing constants).
Topic archived. No new replies allowed.
Pages: 12