#include<iostream>
using namespace std;
class Goldfish /*This creates a class with the name Goldfish", do not
capitalize the 'c' in class! A class is like a
set of declarations to default for
an object, more on that later Public members of the class, can be accessed (used and/or
called) by anything in the program */
{
public:
Goldfish(); /*This is the class's
constructor, must have the same name as the class, more later*/
void setAmount(int); /*A function of the class, returning nothing but taking an
integer*/
void print(); /*Void
function, just prints variables*/
void setColor(char*);
/*Void function that takes a name*/
private:
/*Private data members can only be accessed by other
parts of the class*/
int amount; /*An integer,
the amount of goldfish*/
char *color; /*A pointer to
a character array, AKA string*/
int crunch_level; /*Another integer, how crunchy a bag is (stupid packaging
companies) */
}; /*remember
the damn semicolon on the end of the class, many smart programmers have fallen
to this hell of a beast! */
Goldfish::Goldfish() /*This is the constructor, yes you must have
Goldfish::" in front of the class functions. Constructors don’t have
any return type. */
{
amount=237;
color="orange"; /*Sets the private data members to default values*/
}
void Goldfish::setAmount(int num) /*public function,
allows the amount of goldfish to be changed*/
{
amount=num;
}
void Goldfish::setColor(char *col) /*public
function, allows the color of goldfish to be changed*/
{
color=col;
}
void Goldfish::print () /*Prints the number of goldfish*/
{
cout<<amount<<endl;
cout<<color<<endl;
}
main()
{
Goldfish bag1, bag2; /*This creates 2 objects of the class Goldfish, one named
bag1, one bag2*/
bag1.print(); /*This
calls the print function via bag1, so it prints bag1's amount, no one else's*/
bag1.setAmount(20000); /*Sets the amount of bag1*/
bag1.print(); /*Prints
it again*/
return
0;
}

#include<iostream>
using namespace std;
class Meat
{
public:
Meat(char* = "Beef"); /*If
no *char is entered, it defaults to "Beef", this is called
"defaulting the constructor"*/
void printMeat(void);
private:
char *cut; /*private data
member: character pointer*/
};
Meat::Meat(char *food) /*constructor
takes in a character array*/
{
cut=food; /*Assignings
the intake to a PDM(Private data member) */
}
void Meat::printMeat(void) /*just prints the
kind of meat in the object*/
{
cout<<"The meat is
"<<cut<<".\n";
}
main()
{
Meat one; /*makes
a object that gets defaulted because you don't send the constructor anything*/
Meat two("Steak"); /*because something is entered, it ignores the default*/
one.printMeat();
two.printMeat();
return
0;
}
