KrisLodz


I was reading about garbage collected heap when the following example occured:
ref class MyClass {
public:
MyClass() : i(){}
int i;
void Test() {
i++;
System::Console::WriteLine(i);
}
};

MyClass() : i(){} - can sombody tell me how i is initialized   


Re: Visual C++ Language garbage collected heap

Pintu Shukla

Have a look on C++ Book. And Read Initialization List from That.

Thanx






Re: Visual C++ Language garbage collected heap

einaros

KrisLodz wrote:

MyClass() : i(){} - can sombody tell me how i is initialized   


Well in this particular case it wouldn't do much, as i would be initialized to zero even without an initializer in the constructor, or an assignment within the constructor body.

The point of this example, however, may be initializer lists as such. They allow you to set variables and pass parameters to base constructors, prior to entering the constructors body. If you wish to initialize i to something other than 0, you could write the constructor such as:

MyClass() : i(42) {}

Or, if MyClass was derived from a class MyBase, you could pass a parameter to the MyBase constructor (while still initializing i) such as:

MyClass() : i(42), MyBase(24) {}





Re: Visual C++ Language garbage collected heap

KrisLodz


thanks alot, currently i am learning visual c++ and starting to discover features of visual studio, do you maybe have some good online locations to check out, couse the msdn support is quite scattered, you have to know what you are looking for, i would like something like general tutorial,

thanks




Re: Visual C++ Language garbage collected heap

Pintu Shukla

Here is Some link
C++ Tutorial


VC++ Tutorial

Thanx





Re: Visual C++ Language garbage collected heap

einaros

KrisLodz wrote:

thanks alot, currently i am learning visual c++ and starting to discover features of visual studio, do you maybe have some good online locations to check out, couse the msdn support is quite scattered, you have to know what you are looking for, i would like something like general tutorial,


You should consider getting Accelerated C++. That's a great C++ beginners book, and it would bring you up to speed in no time Smile





Re: Visual C++ Language garbage collected heap

KrisLodz


i was learning c++ for some time, i was thinking more about vc++ and visual studio environment