hi i am trying to "divide" the following code...so that it has a header file and the main file. i tried to seperate the it but when i do it says "nothing to do at all" or "nothing happened at all"(one of them)
ere is the original code. can you pls seperate it into one that a "dog.h" and "dog.cpp"
p.s. i'll appreciate it if you could do this as fast as you can cuz i have a test that i'm supposed to do the same to a similar code.
#include <iostream>
using namespace std;
class Dog {
private:
int age;
int weight;
public:
Dog();牋牋牋//Constructor
~Dog();牋牋//Destructor
void setAge(int age);
int getAge();
void setWeight(int weight);
int getWeight();
void speak();
};
Dog::Dog()
{
age = 0;
weight = 0;
cout << "Dog Constructor Called" << endl;
}
Dog::~Dog()
{
cout << "Dog Destructor Called" << endl;
}
void Dog::setAge(int age)
{
this->age = age;
}
int Dog::getAge()
{
return age;
}
void Dog::setWeight(int weight)
{
this->weight = weight;
}
int Dog::getWeight()
{
return weight;
}
void Dog::speak()
{
cout << "BARK!!" << endl;
}
int main()
{
Dog fido;
Dog rover;
cout << "Rover is " << rover.getAge() << " years old." << endl;
cout << "He weighs " << rover.getWeight() << " lbs." << endl;
cout << endl;
cout << "Updating Rover's Age and Weight" << endl;
rover.setAge(1);
rover.setWeight(10);
cout << "Rover is " << rover.getAge() << " years old." << endl;
cout << "He weighs " << rover.getWeight() << " lbs." << endl;
cout << endl;
cout << "Fido is " << fido.getAge() << " years old." << endl;
cout << "He weighs " << fido.getWeight() << " lbs." << endl;
cout << "Setting Fido to be the same as Rover" << endl;
fido = rover;
cout << "Fido is " << fido.getAge() << " years old." << endl;
cout << "He weighs " << fido.getWeight() << " lbs." << endl;
rover.speak();
fido.speak();
return 0;
}