示例#1
0
int main()
{
    std::cout << "Creating trike named wichita ...";
    Tricycle wichita;
    wichita.pedal();
    std::cout << "Creating trike named dallas ...\n";
    Tricycle dallas(wichita);
    std::cout << "wichita's speed: " << wichita.getSpeed() << "\n";
    std::cout << "dallas's speed: " << dallas.getSpeed() << "\n";
    std::cout << "setting wichita to 10 ...\n";
    wichita.setSpeed(10);
    std::cout << "wichita's speed: " << wichita.getSpeed() << "\n";
    std::cout << "dallas's speed: " << dallas.getSpeed() << "\n";
    return 0;
}
示例#2
0
Tricycle::Tricycle(const Tricycle& rhs)
{
    speed = new int;
    *speed = rhs.getSpeed();
}