RosettaCodeData/Task/Classes/BaCon/classes-2.bacon

35 lines
811 B
Plaintext

PRAGMA COMPILER g++
PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -fpermissive
OPTION PARSE FALSE
'---The class does the declaring for you
CLASS Books
public:
const char* title;
const char* author;
const char* subject;
int book_id;
END CLASS
'---pointer to an object declaration (we use a class called Books)
DECLARE Book1 TYPE Books*
'--- the correct syntax for class
Book1 = new Books()
'--- initialize the strings const char* in c++
Book1->title = "C++ Programming to bacon "
Book1->author = "anyone"
Book1->subject ="RECORD Tutorial"
Book1->book_id = 1234567
PRINT "Book title : " ,Book1->title FORMAT "%s%s\n"
PRINT "Book author : ", Book1->author FORMAT "%s%s\n"
PRINT "Book subject : ", Book1->subject FORMAT "%s%s\n"
PRINT "Book book_id : ", Book1->book_id FORMAT "%s%d\n"