[ create a new paste ] login | about

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

C, pasted on Mar 31:
#include <iostream>
using namespace std;

class First
{
int x;
public:
void setx(int var) {
x = var;
}
 int getx() { //定義 friend 函數
return x;
}
};

class Second
{
int y;
public:
void sety(int var) {
y = var;
}
void showxy(First obj) {
cout << "x = " << obj.getx() << endl; 
cout << "y = " << y << endl;
}
};

int main()
{ 
First A;
Second B;
A.setx(10);
B.sety(20);
B.showxy(A);
system("PAUSE"); 
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 2: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace'
Line 4: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'First'
Line 16: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Second'
In function 'main':
Line 31: error: 'First' undeclared (first use in this function)
Line 31: error: (Each undeclared identifier is reported only once
Line 31: error: for each function it appears in.)
Line 31: error: expected ';' before 'A'
Line 32: error: 'Second' undeclared (first use in this function)
Line 32: error: expected ';' before 'B'
Line 33: error: 'A' undeclared (first use in this function)
Line 34: error: 'B' undeclared (first use in this function)


Create a new paste based on this one


Comments: