Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Simple C++ Class Example


Marsh
 Share

Recommended Posts

Seeing that destructor and the way the declarations for the constructor and the code for it are split up made me cringe.. like bad.

class Gun

{

public string Model { get; set; }

public int RoundCount { get; set; }

public float Range { get; set; }

public Gun(int count, string model, float range)

{

this.RoundCount = count;

this.Model = model;

this.Range = range;

}

}

So much easier.
Link to comment
Share on other sites

  • 2 months later...
Also, you dont have to do that. It is done on purpose for OOP reasons. Its so you can take one quick look at a header file and know how to use the whole class without reading the code. You can put it all in one big spot if you want.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...