Skip to content
Open

Main #10

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Ch00/CodeDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ int main(){
std::cout << "The result of the addition is " << result << std::endl;

std::cout << std::endl << std::endl;
return (0);
return (0); // my comment
}
23 changes: 14 additions & 9 deletions src/Ch03/03_03b/CodeDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@ enum class cow_purpose {dairy, meat, hide, pet};

class cow{
public:
cow(std::string name_i, int age_i, cow_purpose purpose_i){
cow(std::string name_i, int age_i, cow_purpose purpose_i)
{
name = name_i;
age = age_i;
purpose = purpose_i;
}
std::string get_name() const{
std::string get_name() const
{
return name;
}
int get_age() const{
int get_age() const
{
return age;
}
cow_purpose get_purpose() const{
cow_purpose get_purpose() const
{
return purpose;
}
private:
Expand All @@ -29,11 +33,12 @@ class cow{
cow_purpose purpose;
};

int main(){
cow my_cow;
my_cow.age = 5;
my_cow.name = "Betsy";
my_cow.purpose = cow_purpose::dairy;
int main()
{
cow my_cow( "Betsy", 5, cow_purpose::dairy);
// my_cow.age = 5;
// my_cow.name = "Betsy";
// my_cow.purpose = cow_purpose::dairy;
std::cout << my_cow.name << " is a type-" << (int)my_cow.purpose << " cow." << std::endl;
std::cout << my_cow.name << " is " << my_cow.age << " years old." << std::endl;

Expand Down