Mega Code Archive

 
Categories / Visual C++ .NET / Structure
 

Initialize a Structure

#include "stdafx.h" #using <mscorlib.dll> using namespace System; struct Book {     char *Title;     char *Artist;     int YearReleased;     Book(char *t, char *a, int y) {         Title = t; Artist = a; YearReleased = y;     } }; int main(void) {     Book b1("A","B",2001);     Book *b2 = new Book("A","B",1974);     Console::WriteLine(b1.Artist);     Console::WriteLine(b2->Artist);     return 0; }