You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
950 B
60 lines
950 B
10 years ago
|
/*
|
||
9 years ago
|
* Copyright (c) 2013 - present Facebook, Inc.
|
||
|
* All rights reserved.
|
||
|
*
|
||
|
* This source code is licensed under the BSD style license found in the
|
||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||
|
*/
|
||
10 years ago
|
|
||
|
using namespace std;
|
||
|
|
||
9 years ago
|
namespace foo {
|
||
|
typedef struct {
|
||
|
int a;
|
||
|
int b;
|
||
|
} my_record;
|
||
|
int value() { return 5; }
|
||
|
|
||
|
class Rectangle {
|
||
|
int width, height;
|
||
|
|
||
|
public:
|
||
|
void set_values(int, int);
|
||
|
int area(void);
|
||
|
};
|
||
10 years ago
|
}
|
||
|
|
||
9 years ago
|
namespace bar {
|
||
|
const double pi = 3.1416;
|
||
|
double value() { return 2 * pi; }
|
||
10 years ago
|
|
||
9 years ago
|
class Rectangle {
|
||
|
int width, height;
|
||
10 years ago
|
|
||
9 years ago
|
public:
|
||
|
void set_values(int, int);
|
||
|
int area(void);
|
||
|
} rect;
|
||
10 years ago
|
}
|
||
|
|
||
9 years ago
|
int main() {
|
||
10 years ago
|
|
||
9 years ago
|
int i;
|
||
|
double j;
|
||
10 years ago
|
|
||
9 years ago
|
foo::my_record x;
|
||
10 years ago
|
|
||
9 years ago
|
bar::Rectangle rect1;
|
||
|
rect1.set_values(3, 4);
|
||
10 years ago
|
|
||
9 years ago
|
foo::Rectangle rect2;
|
||
|
rect2.set_values(7, 10);
|
||
10 years ago
|
|
||
9 years ago
|
x.a = 10;
|
||
|
i = foo::value();
|
||
|
i = bar::value();
|
||
|
j = bar::pi;
|
||
|
return 0;
|
||
10 years ago
|
}
|