Version info in cout.

Aug 26, 2014 at 1:22am
Hello, I'm new to C++ I started it like a week ago in this class I'm taking.

So i'm making some little fun adventure thing and at the beginning I want to display the version of the game. I was wondering if there was a way to implement the version info from the project properties into a cout message thing.

Thanks!
Aug 26, 2014 at 1:27am
Are you just using console application(no images and stuff)?
Aug 26, 2014 at 1:29am
yeah, that's all we're doing in the class so far. i think later on the school year we'll be doing stuff with images
Aug 28, 2014 at 2:42pm
So is there a way to do this..?
Aug 28, 2014 at 2:51pm
Have a header file in your project containing integers constants to hold your major/minor version number. then have a method to build up a string of this eg:

1
2
3
4
5
std::string GetVersionNumber()
{

....// build up the version string e.g. "12.4.2"
}


then call this when you want to print it.
Aug 28, 2014 at 2:57pm
What platform?

Windows (.NET) has the Version class.
http://msdn.microsoft.com/en-us/library/system.version(v=vs.110).aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-1

It would be a whole lot simpler to include a version variable in your source code and update it when you change your program.

1
2
3
4
 
  const string program_version = "1.0";

  cout << "My game version: " << program_version << endl;


Last edited on Aug 28, 2014 at 3:00pm
Topic archived. No new replies allowed.