Operator Overloading in Value class

I was reading this code in a book and i dont get it can any body tell me what is going on in this??
this was about operator overloading in value class....


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 value class Length
{
private:
int feet; // Feet component
int inches; // Inches component
public:
static initonly int inchesPerFoot = 12;
// Constructor
Length(int ft, int ins) : feet(ft), inches(ins){ }
// A length as a string
virtual String^ ToString() override
{
return feet.ToString() + (1 == feet ? L" foot " : L" feet ") +
inches + (1 == inches ? L" inch" : L" inches");
}
// Addition operator
Length operator+(Length len)
{
int inchTotal = inches+len.inches+inchesPerFoot*(feet+len.feet);
return Length(inchTotal/inchesPerFoot, inchTotal%inchesPerFoot);
}
}; 

Actualy i dont get the whole code Plz help me in figuring out this ....
To begin with, this isn't C++ at all.
I can only assume this is not C++ or you made a few typos when copying the code.
It's C++/CLI I am fairly positive of.
http://msdn.microsoft.com/en-us/library/ms235240.aspx
I read this code in c++ book
Would you please give us the name of the book and author? I am 95% positive it is c++/cli and not c++.
IVOR HORTON’S
BEGINNING VISUAL C++® 2010
This is the name of the book
Visual C++ != C++ though AFAIK the caret(^) and initonly are C++/CLI features. Looking at some of the reviews the book goes over C++/CLI, Visual c++ and c++. If you wish to learn only c++ I would suggest checking out the tutorials on this site, http://www.learncpp.com/ or http://www.parashift.com/c++-faq/

Here is also a list of books: http://www.cplusplus.com/faq/beginners/books/
closed account (z05DSL3A)
Visual C++ != C++ though...

Visual C++ is a product not a language, you are quite capable of doing C++ and C++/CLI with it... and quite probably C++/CX (that also uses ^).
Topic archived. No new replies allowed.