Primeiros exemplos de classes em livros de C++ ---- 1 livro brasileiro (2010) -> sintética ------- Moving from C to C++: Discussing Programming Problems, Why They Exist, and How C++ Solves Them Arunesh Goyal Apress 2013 1o fala de maneira sintética bem alto nível -> tipo Apresenta classe Lampada Tipo abstrato de dados Apresenta herança sinteticamente base/derivada Discute várias classes pré-definidas string stream vector(!!!) primeira definição: sintética struct A { private: int i, j, k; public: int f(); void g(); }; class B { int i, j, k; public:int f();void g(); }; --------------------------------------------- C++ for Engineers and Scientists Third Edition Gary J. Bronson,G.J. Borse 2010 1o classe sintética class Date{ private: // notice the colon after the word private int month; // a data member int day; // a data member int year; // a data member public: // again, notice the colon here Date(int = 7, int = 4, int = 2005); // a member function - // the constructor void setDate(int, int, int); // a member function void showDate(); // a member function }; ------------------------------------------------- C++ from the Ground Up Third Edition Herbert Schildt 2003 1a classe semanticamente significativa bem simples mas já com seção public... class queue { int q[100]; int sloc, rloc; public: void init(); void qput(int i); int qget(); }; ---------------------- C++ How to Program, Fifth Edition H. M. Deitel P. J. Deitel Prentice Hall 2005 1a classe semanticamente significativa bem simples e vai adicionando elementos... class gradeBook 1o só uma função que escreve "hello" ----------- C++ Programming Fundamentals Chuck Easttom ISBN:1584502371 Charles River Media, 2003 1a classe sintética (tentando dar significado) #include using namespace std; class myfirstclass{ public: int number; void greeting(); }; void myfirstclass::greeting(){ for(int i = 0; i<= number;i++){ cout<< "Hello World \n"; } } int main (){ myfirstclass myfirstobject; myfirstobject.number =3; myfirstobject.greeting(); return 0; } -------------------------------------- C++ Programming for the Absolute Beginner by Dirk Henkemans, Mark Lee ISBN:1931841438 Premier Press 2001 uma classe sintética muito simples &rápida quase inexistente e uma classe arco!! (bow) já com construtor e destrutor class Bow{ //data member declarations string color; bool drawn; int numOfArrows; Bow(string aColor); //constructor ~Bow(); //destructor //methods void draw(); int fire(); }; ------------ Sams Teach Yourself C++ in One Hour a Day Jesse Liberty Siddhartha Rao Bradley Jones 2009 Sams Publishing class Cat{ unsigned int itsAge; unsigned int itsWeight; void Meow(); }; void Cat::Meow(){ std::cout << “Meow.\n”; } ------------- Thinking In C++ Second Edition Bruce Eckel Prentice Hall 2000 Prefere mostrar que podemos definir funções de uma estrutura... ou seja classes são como estruturas (estado) onde podemos definir comportament (funções) struct com semântica struct Stash { int size; // Size of each space int quantity; // Number of storage spaces int next; // Next empty space // Dynamically allocated array of bytes: unsigned char* storage; // Functions! void initialize(int size); void cleanup(); int add(const void* element); void* fetch(int index); int count(); void inflate(int increase); }; ///:~ ------------------ Intermediate Business Programming with C++ Don Voils White Feather Publishing 2007 Sintética, já incluindo a definição de private/public/protected class className{ private: memberDataType dataMemberlist; memberFunctionlist; protected: memberDataType dataMemberlist; memberFunctionlist; public: memberDataType dataMemberlist; memberFunctionlist; }; 1a classe sabidamente errada: class Date{ int theMonth, theDay, theYear; }; ----------------------------------