[ create a new paste ] login | about

Link: http://codepad.org/YTPwJLWr    [ raw code | output | fork ]

C, pasted on May 15:
#include <iostream>
#include <string>

class Person {
private:
    std::string name;
public:
    Person(std::string n) : name(n) {}
    std::string getName() const {
        return name;
    }
};

class Love {
private:
    const Person& lover1;
    const Person& lover2;
public:
    Love(const Person& p1, const Person& p2) : lover1(p1), lover2(p2) {}
    void express() const {
        std::cout << lover1.getName() << " và " << lover2.getName() << " hãy mãi yêu nhau!\n";
    }
};

int main() {
    Person person1("Alice");
    Person person2("Bob");
    
    Love love(person1, person2);
    love.express();
    
    return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
Line 19: error: iostream: No such file or directory
Line 17: error: string: No such file or directory
Line 4: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Person'
Line 14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Love'
In function 'main':
Line 26: error: 'Person' undeclared (first use in this function)
Line 26: error: (Each undeclared identifier is reported only once
Line 26: error: for each function it appears in.)
Line 26: error: expected ';' before 'person1'
Line 27: error: expected ';' before 'person2'
Line 29: error: 'Love' undeclared (first use in this function)
Line 29: error: expected ';' before 'love'
Line 30: error: 'love' undeclared (first use in this function)


Create a new paste based on this one


Comments: