I've just started learning c++ these past couple of months, and there's so much I haven't been exposed to. I've tried searching for this syntax, but with no success. It's from an exercise on programmr.com which concerns classes and operator overloading. Here's the code:
class temp
{
int value;
public:
temp(int v=0) : value(v) { }
I understand it's declaring a class called "temp", with a private member variable "value". I'm guessing the code under "public" is declaring a default constructor. I'm used to seeing default constructors declared in function syntax:
temp (int v=0){
value = v;
some expressions;
}
The part I'm confused about is after the colon:
: value(v) {}
What is the function of the colon there, exactly? What is the relationship between the default constructor and "value(v) {}"? Is this just a different syntax of the function-style default constructor I gave an example of above? Thanks for helping out this total n00b!